🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more

github.com/nekoshita/twitter-api-example-by-golang

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/nekoshita/twitter-api-example-by-golang

v0.0.0-20210314030158-fc0275b5412a
Version published
Created

twitter api example

これはなに?

TwitterのAPIをたたくサンプル実装

TwitterのAPI叩くためには何が必要?

Twitter APIの公式ドキュメントは?

https://developer.twitter.com/en/docs/twitter-api/v1

Twitter APIの認証について

  • 全てのAPIをたたくには、TwitterDeveloperPortalで作成したAppの Consumer Keys による認証が必要
  • 特定のユーザーに対するアクション(フォローするなど)などのAPIを叩く場合は、Consumer Keys に加え、Twitter UserのAccess Tokenが必要
  • Twitter UserのAccess Tokenの取得方法

サンプルの種類

  • no-user-context-api
    • ユーザー認証が不要なAPIをたたくサンプル
    • ツイートを検索したり、ユーザーのタイムラインを取得するだけならこれ
  • user-context-api-by-app-owner
    • ユーザー認証が必要なAPIをたたくサンプル
    • Twitter Appのオーナーのユーザーを認証する前提なので、Access TokensはTwitterDeveloperPortalで発行する前提
    • 不特定多数のTwitter UserにTwitter Sign-inを要求しないが、ユーザー認証が必要なAPIを叩く場合はこれ
  • user-context-api-by-any-user
    • ユーザー認証が必要なAPIをたたくサンプル
    • 不特定多数のTwitter UserにTwitter Sign-inを要求し、それぞれのTwitter UserのAccess Tokensを使ってユーザー認証が必要なAPIを叩く場合はこれ
    • たとえば、Twitter Sign-inに対して、フォローするAPIをたたいてあげる、みたいなことやる場合はこれ

使用したライブラリ

Twitter APIを使えるライブラリ一覧はこちら https://developer.twitter.com/en/docs/twitter-api/tools-and-libraries

今回はGo言語のライブラリを使いました https://github.com/dghubble/go-twitter

機密情報の取り扱いについて

FAQs

Package last updated on 14 Mar 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts