The feedly Cloud APIではてなブックマークお気に入りのタイトルを表示

f:id:fedora9:20201027201316p:plain

The feedly Cloud API

 

以下のリンクを開き、Googleのhiroyuki12でログインして、developer access tokenを取得

feedly cloud | developer

Gmailに届いたメールのリンクを開いてdeveloper access tokenを取得。 

 

Developer Access Tokens | feedly Cloud API

 

Feedly APIAWS Lambdaから実行する) 

リージョン us-east-1 で作成した

Lambda - CallFeedlyAPI -設定 - 環境変数で設定

 

 

profileを取得して表示

$ curl -H "Authorization: OAuth yourAccessTokenValueGoesHere" https://cloud.feedly.com/v3/profile

Overview | feedly Cloud API v3

 

Terminalでjsonを整形して表示できるようにjqをインストールする。

$ b jq

Macでjsonを見やすく整形する方法 - Qiita

 

フィードの未読数を取得

$ curl -H "Authorization: OAuth yourAccessTokenValueGoesHere" https://cloud.feedly.com/v3/markers/counts | jq

Feedly APIメモ - Qiita

 

BORDS一覧を取得

$ curl -H "Authorization: OAuth yourAccessTokenValueGoesHere" https://cloud.feedly.com/v3/boards | jq

 

collections(FEEDSの下にあるカテゴリ)一覧を取得(feedsのfeedid他も取得)

$ curl -H "Authorization: OAuth yourAccessTokenValueGoesHere" https://cloud.feedly.com/v3/collections | jq

 

categories(FEEDSの下にあるカテゴリ)一覧を取得 (idとlabelとcreatedのみ)

$ curl -H "Authorization: OAuth yourAccessTokenValueGoesHere" https://cloud.feedly.com/v3/categories | jq

How to get all unread items using Feedly API - Stack Overflow

 

⭐️categoryがItの未読の記事のタイトル他を取得

$ curl -H "Authorization: OAuth yourAccessTokenValueGoesHere"  'https://cloud.feedly.com/v3/streams/contents?streamId=user/yourUserIdGoesHere/category/It&unreadOnly=true' | jq

How to get all unread items using Feedly API - Stack Overflow

 

⭐️categoryがglobal.uncategorizedの記事のタイトル他を取得

$ curl -H "Authorization: OAuth yourAccessTokenValueGoesHere"  'https://cloud.feedly.com/v3/streams/contents?streamId=user/yourUserIdGoesHere/category/global.uncategorized' | jq

yourAccessTokenValueGoesHereと yourUserIdGoesHereは実際の値に置き換え

 

ios - How to set a 'Token xxxxxxxxxx' for 'Authorization' in HTTP header in URLSession - Stack Overflow

    let url: URL = URL(string: str7)!

    var request = URLRequest(url: url)

    request.setValue(Constants.feedlyDeveloperToken, forHTTPHeaderField: "Authorization")

    let task: URLSessionTask  = URLSession.shared.dataTask(with: request, completionHandler: {data, response, error in

 

リンクのURLはalternateの下のhrefにある

    let array = articles[indexPath.row]["alternate"] as! NSArray

    for roop in array {

      let next = roop as! NSDictionary

      //print(next["href"])

      webView.url = next["href"] as? String

    }

Swift - NSSingleObjectArrayIとは?|teratail

 

Swiftで日時文字列とUNIX時間を相互に変換する方法 - Qiita

    // セルに表示する作成日を設定する

    let tagsText = cell.viewWithTag(4) as! UILabel

    let dateUnix = (article["published"]! as? Double)! / 1000 // items->creation_date

    let date = NSDate(timeIntervalSince1970: dateUnix)

    let formatter = DateFormatter()

    formatter.dateFormat = "yyyy-MM-dd HH:mm:ss"

    let dateStr: String = formatter.string(from: date as Date)

    tagsText.text = author + " " + daysAgo(dateStr)

 

curl コマンド 使い方メモ - Qiita

$ curl -H

 

Streams | feedly Cloud API

continuation=publishedの値

publishedの値より前の記事を取得

https://cloud.feedly.com/v3/streams/contents?streamId=user/" + Constants.feedlyUserId + "/category/global.uncategorized&continuation=" + continuation

 

はてなスタッフ - はてなブログ グループ

feedlyのCreate New Feedでcategoryを作成

Addで追加

$ curl -H "Authorization: OAuth yourAccessTokenValueGoesHere" https://cloud.feedly.com/v3/categories | jq

で、idのcategoryの後ろを確認

 

はてなブログ グループのRSSフィード - Sprint Life

 

Feedly にはてなブックマーク数を表示する Chrome 拡張 - yunica's blog

 

sandbox

FeedlyClient/Constants.swift at 8c74a5b1d6840e459c113f6a1134ad8e3086d890 · florinmunteanu/FeedlyClient · GitHub

 

Swiftの記事一覧 | Zenn

 

Next.js から Feedly API を叩いて記事データを取得する | WWW WATCH

Time ago extention

f:id:fedora9:20201018232515p:plain

“Time ago” Date extension in Swift | by JD | Medium

 

【Swift】Substringを簡単にしたい | 2速で歩くヒト

 

  func daysAgo(_ data: String) -> String {

    let calendar = Calendar.current

    let dateComponents = DateComponents(calendar: calendar, year: Int(data[0...3]), month: Int(data[5...6]), day: Int(data[8...9]), hour: Int(data[11...12]), minute: Int(data[14...15]), second: Int(data[17...18]))

    if let date = calendar.date(from: dateComponents) {

      return date.timeAgo()

    }

    return ""

  }

 

    // セルに表示する作成日を設定する

    let textDetailText = cell.viewWithTag(3) as! UILabel

    textDetailText.text = daysAgo((article["created_at"] as? String)!)

 

NSDate を相対時刻にするライブラリ - 大学生からの Web 開発

 

はてなブックマーク お気に入りフィードのタイトルを表示

Swift4でRSSリーダーをつくろう - @mizumotokのブログ

f:id:fedora9:20201017125714p:plain

$ git clone https://github.com/mizumotok/rss-reader-swift4

Xcodeでxcodeprojファイルを開く

ViewController.swiftのfeedUrlを変更して実行

  let feedUrl = URL(string: "https://b.hatena.ne.jp/fedora9/favorite.rss?key=xxxxxxxx")!

  

NoteのAPIでカテゴリがテクノロジーのタイトルを表示 を元に、

画面とViewControllerをコピーして、作成

 

https://b.hatena.ne.jp/fedora9/favorite

 

お気に入りフィードのURL

https://b.hatena.ne.jp/fedora9/favorite.rss?key=xxxxxxxx

HBFavが使えなくなったので代替策を考える - braitom's Tech Memo

 

Swiftの最新記事 RSS

http://b.hatena.ne.jp/search/tag?q=swift&users=1&mode=rss&page=1

https://b.hatena.ne.jp/search/tag?q=swift&users=1

 

Hotentry RSS

http://b.hatena.ne.jp/hotentry.rss 

はてなブックマーク - 人気エントリー - 総合

 

IT RSS

http://b.hatena.ne.jp/hotentry/it.rss

はてなブックマーク - 人気エントリー - テクノロジー

 

はてなブックマークお気に入りフィード仕様 - Hatena Developer Center

 

Consumer key を取得して OAuth 開発をはじめよう - Hatena Developer Center

 

until / of / with_me のパラメータは廃止されました。

お気に入りフィードRSSの継続および仕様変更について - はてなブックマーク開発ブログ

 

 

Safariでウェブページのソースコードを見る方法。(HTML & CSS)

  

RSS to JSON Converter online - rss2json.com

https://api.rss2json.com/v1/api.json?rss_url=https%3A%2F%2Fb.hatena.ne.jp%2Ffedora9%2Ffavorite.rss%3Fkey%3Dxxxxxxxxxx

出力されるアイテムの数はデフォルト10

RSSをJSONに変換してくれるWebサービス「rss2json」の紹介 - Qiita

 

b.hatena.ne.jp/favorite.rss で検索

Sign in to GitHub · GitHub

 

GitHub - YuheiNakasaka/RNHBFav: HBFavのReactNative版

 

 MACアプリ

GitHub - Nyoho/HatebLine: A macOS application that shows your favorites of Hatena Bookmark as a timeline like HBFav

$ git clone https://github.com/Nyoho/HatebLine

$ cd HatebLine

$ carthage update --OSX

f:id:fedora9:20201015023219p:plain

 

GitHub ActionsとGitHub PagesでつくるWeb API(郵便番号検索) - @mizumotokのブログ

RSSリーダ

SwiftでシンプルなRSSリーダーを作る(Yahooニュース編) - Qiita

 

$ git clone https://github.com/kawano108/YahooNewsMirror

$ cd YahooNewsMirror

$ pod install

Xcodeでxcworkspaceファイルを開き、実行

f:id:fedora9:20201014224652p:plain

RSS一覧 - Yahoo!ニュース

 

NewsType.swift

RSSXMLでデータを返しますが、より汎用的に使えるJSONで記事を取得したいのでJSON変換するAPIを通しています。

 

SwiftだけでRSSリーダーを作ってみた - Eureka, Inc.