🌊
Instagram API のアクセストークン取得手順
取得手順
下ごしらえ
- Facebookでページ作成
- instagramをプロアカウントにする
- ページをリンク
トークンを取得していく
-
facebook ログイン
-
meta for Developers アカウント作成
-
新規アプリを作成
-
「その他」を選択
-
Instagram API を追加
-
「アプリの設定」の「ベーシック」を確認
-
「アプリID」と「app secret」をひかえる
-
「グラフAPIエクスプローラ」を起動
-
「ページアクセストークンの取得」を選択
-
「現在のページにのみオプトイン」を選んで、作成したページを選択
-
パーミッション追加
- pages_show_list
- business_management
- pages_read_engagement
- instagram_basic
- instagram_content_publish
- instagram_manage_comments
- instagram_manage_messages
-
「Generate Access Token」を選択して「アクセストークンA」を生成
-
下記のURLにて「アクセストークンB」を取得
https://graph.facebook.com/v21.0/oauth/access_token?grant_type=fb_exchange_token&client_id=【アプリID】&client_secret=【app_secret】&fb_exchange_token=【アクセストークンA】
-
下記のURLにて「id」を取得
https://graph.facebook.com/v21.0/me?access_token=【アクセストークンB】
-
下記のURLにて「アクセストークンC」を取得
https://graph.facebook.com/v21.0/【ID】/accounts?access_token=【アクセストークンB】
-
「アクセストークンデバッガー」を起動
-
「アクセストークンC」でデバッグを選択して「ページID」を取得する
-
下記のURLで「Instagram ID」を取得
https://graph.facebook.com/【アクセストークンデバッガーで確認できるページID】?fields=instagram_business_account&access_token=【トークンC】
-
下記のURLでJSONで投稿を取得できたら成功!
https://graph.facebook.com/v21.0/{インスタグラムID}?access_token={アクセストークンC}&fields=media{like_count,media_url}
Discussion