Twitter APIで、ツイートを表示

 

 

f:id:fedora9:20201127225803p:plainf:id:fedora9:20201127225901p:plain

https://gift-by-gifted.com/twitter-api-suspended/

 

TwitterAPIキーを取得

2020年度版 Twitter API利用申請の例文からAPIキーの取得まで詳しく解説 | 新宿のホームページ制作会社 ITTI(イッティ)

APIキー取得できた 

 

https://developer.twitter.com/en/portal/projects-and-apps

Deeloperサイト

 

【Swift5】Twitterログインしてトークン情報を取得する - Qiita

Loginして、oauth_tokenをアラート表示できた

 

HomeTimeLine, TimeLineをprintで表示できた

 

    let swifter = Swifter(consumerKey: Constants.twitterAPIkey,

                          consumerSecret: Constants.twitterAPIsecretKey,

                          oauthToken: Constants.twitterAccessToken,

                          oauthTokenSecret: Constants.twitterAccessTokenSecret)

    

    // こっちは、連携中のユーザーのフォローしてるユーザーのツイートを時系列順に。

//    swifter.getHomeTimeline(count: 5,success: { json in

//      // 成功時の処理

//      print(json)

//    }, failure: { error in

//      // 失敗時の処理

//      print(error)

//    })

//

    //    こっちは、@~~~で指定したユーザーのツイートを時系列順に取得。

    swifter.getTimeline(for: .screenName("twitter"),success: { json in

      // 成功時の処理

      print(json)

    }, failure: { error in

      // 失敗時の処理

      print(error)

    })

 

ツイートのテキストを表示

    //    こっちは、@~~~で指定したユーザーのツイートを時系列順に取得。

    swifter.getTimeline(for: .screenName("twitter"),success: { json in

      // 成功時の処理

      //print(json)

      print(json.array?[0]["text"].string ?? "")

      

    }, failure: { error in

      // 失敗時の処理

      print(error)

    })

Swifterの使い方 | Love & Geek

 

max_idを指定して、取得する範囲をずらせる

swifter.getTimeline(for: .screenName(self.screenName), maxID: maxId, success: { json in

        guard let json2 = json.array else {

          return

        }

        

        if json2.count > 0 {

          self.maxId = json.array?[json2.count-1]["id_str"].string ?? ""

        }

#Twitter #API でページめくりをして200件超のツイートを取得する #python スクリプトの例 - Qiita

 

リプライのツイートは除く excludeReplies

      swifter.getTimeline(for: .screenName(self.screenName), excludeReplies: true, success: { json in

 

getTimelineを右クリックしてJump to Definitionで定義を確認できる

    func getTimeline(for userTag: UserTag,

                     customParam: [String: Any] = [:],

                     count: Int? = nil,

                     sinceID: String? = nil,

                     maxID: String? = nil,

                     trimUser: Bool? = nil,

                     excludeReplies: Bool? = nil,

                     includeRetweets: Bool? = nil,

                     contributorDetails: Bool? = nil,

                     includeEntities: Bool? = nil,

                     tweetMode: TweetMode = .default,

                     success: SuccessHandler? = nil,

                     failure: FailureHandler? = nil) {

 

Twitter - TwitterAPI error:401の解決方法が知りたい|teratail

 

GET statuses/home_timeline | Docs | Twitter Developer

 

ツイートのIDを指定してツイートを取得

curl -H "Authorization:Bearer {Bearer Token}" "https://api.twitter.com/2/tweets/1312028311011438592"

Twitter API v2.0について – アプリ認証編 – | アシアルブログ

 

ツイートのIDを指定してツイートを取得 

curl -H "Authorization:Bearer {Bearer Token}" "https://api.twitter.com/2/tweets/1312028311011438592?tweet.fields=attachments,author_id,created_at,entities,geo,id,in_reply_to_user_id,lang,possibly_sensitive,referenced_tweets,source,text,withheld"

Twitter API v2

GET /2/tweets | Docs | Twitter Developer

 

ユーザーIDを指定して、ユーザーネームを取得

curl -H "Authorization:Bearer {Bearer Token}" "https://api.twitter.com/2/users/783214"

Twitter API v2

 

ユーザーネームを指定して、ユーザーIDを取得

curl -H "Authorization:Bearer {Bearer Token}" "https://api.twitter.com/2/users/by/username/Twitter"

Twitter API v2

 

Sampled Stream

curl -H "Authorization:Bearer {Bearer Token}" "https://api.twitter.com/2/tweets/sample/stream"

Twitter API v2

 

v1.1

GET statuses/home_timeline - ホームタイムラインを取得する

 

 

TwitterAPIとSwiftを使ってiOSアプリを作ろう! - 前編 - #dotsgirls - Qiita

TwitterAPIとSwiftを使ってiOSアプリを作ろう! - 後編 - #dotsgirls - Qiita

2/19 TwitterAPIとSwiftを使ってiOSアプリを作ろう!を開催しました #eventdots - とりあえずやってみればいいじゃん

 

Swifterの使い方 - Qiita

 pod 'Swifter', :git => 'https://github.com/mattdonnelly/Swifter.git'

 

【swifter】Twitter連携アプリを作るためのswifterの主な関数の使い方の記録 - Qiita

 

  • Consumer Key (API Key)
  • Consumer Secret (API Secret)

hawksnowlog: Swifter を使って iOS アプリからつぶやいてみた

 

【API・データ検証奮闘記】#1.Twitter APIやってみた | DataCurrent

 

【Python×TwitterAPI】Twitterクライアント作成までの道【APIで遊ぶ編】 - RAKUS Developers Blog | ラクス エンジニアブログ

 

Twitter API v2.0について – アプリ認証編 – | アシアルブログ

 

ベアラートーク

Twitter REST APIの使い方

 

GET statuses/home_timeline - ホームタイムラインを取得する

 

【PHP×Twitter API】タイムラインの取得と表示の基本 | 無能投資家の苦悩

 

split

SwiftでString文字列を分割 するには

 

max_id

GET statuses/home_timeline | Docs | Twitter Developer

 

UILabelを複数行表示 – Swift4.0

 

quoted_status

Twitterリツイートに関するJSONについてまとめる - Qiita

 

オブジェクト内のEntities - Twitter 開発者ドキュメント 日本語訳

 

Extended entities object | Docs | Twitter Developer

 

【Python×TwitterAPI】Twitterクライアント作成までの道【APIで遊ぶ編】 - RAKUS Developers Blog | ラクス エンジニアブログ