facebook twitter hatena line email

「Instagram/api」の版間の差分

提供: 初心者エンジニアの簡易メモ
移動: 案内検索
(検索api)
 
(同じ利用者による、間の7版が非表示)
行13: 行13:
  
 
==アクセストークンを取得==
 
==アクセストークンを取得==
  https://api.instagram.com/oauth/authorize/?client_id=[client_id]&redirect_uri=[redirect_uri]&response_type=token
+
  ttps://api.instagram.com/oauth/authorize/?client_id=[client_id]&redirect_uri=[redirect_uri]&response_type=token
  
 
認証するとリダイレクトURL先のパラメータにアクセストークンが表示される
 
認証するとリダイレクトURL先のパラメータにアクセストークンが表示される
行20: 行20:
 
  {"code": 403, "error_type": "OAuthForbiddenException", "error_message": "Implicit authentication is disabled"}
 
  {"code": 403, "error_type": "OAuthForbiddenException", "error_message": "Implicit authentication is disabled"}
  
manage_client/edit/securityからDisable implicit OAuthのチェックを外すときちんとURLのパラメータにアクセストーンが表示されるようになった。
+
manage_client/edit/securityから"Disable implicit OAuth"のチェックを外すときちんとURLのパラメータにアクセストーンが表示されるようになった。
  
 
参考:http://qiita.com/zurg/items/4c423b93b6a7f1ac737d
 
参考:http://qiita.com/zurg/items/4c423b93b6a7f1ac737d
 +
 +
==自身の投稿画像を取得==
 +
ttps://api.instagram.com/v1/users/self/media/recent/?access_token=[access_token]
 +
 +
戻りjson(サンプル)
 +
{
 +
    "data": [
 +
        {
 +
            "attribution": null,
 +
            "caption": {
 +
                "created_time": "1453566461",
 +
                "from": {
 +
                    "full_name": "tarou",
 +
                    "id": "2650465639",
 +
                    "profile_picture": "ttps://scontent.cdninstagram.com/hphotos-xap1/t51.2885-19/s150x150/12534147_1547250855586222_726330116_a_x.jpg",
 +
                    "username": "nihon_tarou"
 +
                },
 +
                "id": "1168922659837838042",
 +
                "text": "Wiiuかったぞー"
 +
            },
 +
            "comments": {
 +
                "count": 0
 +
            },
 +
            "created_time": "1453566461",
 +
            "filter": "Normal",
 +
            "id": "1168922656817938508_2650465639",
 +
            "images": {
 +
                "low_resolution": {
 +
                    "height": 320,
 +
                    "url": "ttps://scontent.cdninstagram.com/hphotos-xpa1/t51.2885-15/s320x320/e35/12534130_230670640603143_771454513_n_x.jpg",
 +
                    "width": 320
 +
                },
 +
                "standard_resolution": {
 +
                    "height": 640,
 +
                    "url": "ttps://scontent.cdninstagram.com/hphotos-xpa1/t51.2885-15/s640x640/sh0.08/e35/12534130_230670640603143_771454513_n_x.jpg",
 +
                    "width": 640
 +
                },
 +
                "thumbnail": {
 +
                    "height": 150,
 +
                    "url": "ttps://scontent.cdninstagram.com/hphotos-xpa1/t51.2885-15/s150x150/e35/12534130_230670640603143_771454513_n_x.jpg",
 +
                    "width": 150
 +
                }
 +
            },
 +
            "likes": {
 +
                "count": 0
 +
            },
 +
            "link": "ttps://www.instagram.com/p/BA42PaRigBM_x/",
 +
            "location": null,
 +
            "tags": [],
 +
            "type": "image",
 +
            "user": {
 +
                "full_name": "tarou",
 +
                "id": "2650465639",
 +
                "profile_picture": "ttps://scontent.cdninstagram.com/hphotos-xap1/t51.2885-19/s150x150/12534147_1547250855586222_726330116_a_x.jpg",
 +
                "username": "nihon_tarou"
 +
            },
 +
            "user_has_liked": false,
 +
            "users_in_photo": []
 +
        },
 +
        {
 +
            "attribution": null,
 +
            "caption": {
 +
                "created_time": "1453566414",
 +
                "from": {
 +
                    "full_name": "tarou",
 +
                    "id": "2650465639",
 +
                    "profile_picture": "ttps://scontent.cdninstagram.com/hphotos-xap1/t51.2885-19/s150x150/12534147_1547250855586222_726330116_a_x.jpg",
 +
                    "username": "nihon_tarou"
 +
                },
 +
                "id": "1168922264583406250",
 +
                "text": "クリスマスセブンで半額1000円でケーキ買ってきた。デザートにしては多すぎた"
 +
            },
 +
            "comments": {
 +
                "count": 0
 +
            },
 +
            "created_time": "1453566414",
 +
            "filter": "Normal",
 +
            "id": "1168922261731278909_2650465639",
 +
            "images": {
 +
                "low_resolution": {
 +
                    "height": 320,
 +
                    "url": "ttps://scontent.cdninstagram.com/hphotos-xfp1/t51.2885-15/s320x320/e35/12407315_1526484167649318_417599452_n_x.jpg",
 +
                    "width": 320
 +
                },
 +
                "standard_resolution": {
 +
                    "height": 640,
 +
                    "url": "ttps://scontent.cdninstagram.com/hphotos-xfp1/t51.2885-15/s640x640/sh0.08/e35/12407315_1526484167649318_417599452_n_x.jpg",
 +
                    "width": 640
 +
                },
 +
                "thumbnail": {
 +
                    "height": 150,
 +
                    "url": "ttps://scontent.cdninstagram.com/hphotos-xfp1/t51.2885-15/s150x150/e35/12407315_1526484167649318_417599452_n_x.jpg",
 +
                    "width": 150
 +
                }
 +
            },
 +
            "likes": {
 +
                "count": 0
 +
            },
 +
            "link": "ttps://www.instagram.com/p/BA42JqUigA9_x/",
 +
            "location": null,
 +
            "tags": [],
 +
            "type": "image",
 +
            "user": {
 +
                "full_name": "tarou",
 +
                "id": "2650465639",
 +
                "profile_picture": "ttps://scontent.cdninstagram.com/hphotos-xap1/t51.2885-19/s150x150/12534147_1547250855586222_726330116_a_x.jpg",
 +
                "username": "nihon_tarou"
 +
            },
 +
            "user_has_liked": false,
 +
            "users_in_photo": []
 +
        }
 +
    ],
 +
    "meta": {
 +
        "code": 200
 +
    },
 +
    "pagination": {}
 +
}
  
 
==検索api==
 
==検索api==
行28: 行145:
 
権限がないので以下のように表示される(2015/11/17からっぽい)
 
権限がないので以下のように表示される(2015/11/17からっぽい)
 
  {"meta":{"error_type":"OAuthPermissionsException","code":400,"error_message":"This request requires scope=public_content, but this access token is not authorized with this scope. The user must re-authorize your application with scope=public_content to be granted this permissions."}}
 
  {"meta":{"error_type":"OAuthPermissionsException","code":400,"error_message":"This request requires scope=public_content, but this access token is not authorized with this scope. The user must re-authorize your application with scope=public_content to be granted this permissions."}}
 +
この先は申請が必要だからテストで使うのは無理っぽいかな・・。
  
 
==APIリクエスト回数限度==
 
==APIリクエスト回数限度==
行36: 行154:
 
==公式マニュアルページ==
 
==公式マニュアルページ==
 
https://www.instagram.com/developer/
 
https://www.instagram.com/developer/
 +
 +
==クローラーの規約==
 +
https://www.facebook.com/help/instagram/478745558852511/
 +
 +
自動装置などを使って本サービス上のあらゆるコンテンツ(ユーザーのプロフィールや写真を含みますが、これに限定されません)を巡回、収集、キャッシングしたり、これにアクセスすることを禁止しています(ただし、標準的な検索エンジンプロトコルまたはInstagramが明示的に認めている検索エンジンが使用する技術を用いる場合を除きます)。

2016年11月29日 (火) 10:01時点における最新版

API申請は2015/11/17以降厳しくなっているらしい

http://www.bricoleur.co.jp/blog/archives/2576

ハッシュ検索も一般ユーザの画像は表示されないようにされているっぽい http://detail.chiebukuro.yahoo.co.jp/qa/question_detail/q14153122184

developer登録

http://instagram.com/developer/clients/manage/

  1. regist new clinetsからアプリケーション作成
  2. Client ID と Client Secret を取得できる
  3. "This app is in sandbox mode and can only be authorized by sandbox users."となるがアプリIDが作成される

アクセストークンを取得

ttps://api.instagram.com/oauth/authorize/?client_id=[client_id]&redirect_uri=[redirect_uri]&response_type=token

認証するとリダイレクトURL先のパラメータにアクセストークンが表示される

きちんと入れたはずだがエラーが発生した。

{"code": 403, "error_type": "OAuthForbiddenException", "error_message": "Implicit authentication is disabled"}

manage_client/edit/securityから"Disable implicit OAuth"のチェックを外すときちんとURLのパラメータにアクセストーンが表示されるようになった。

参考:http://qiita.com/zurg/items/4c423b93b6a7f1ac737d

自身の投稿画像を取得

ttps://api.instagram.com/v1/users/self/media/recent/?access_token=[access_token]

戻りjson(サンプル)

{
   "data": [
       {
           "attribution": null, 
           "caption": {
               "created_time": "1453566461", 
               "from": {
                   "full_name": "tarou", 
                   "id": "2650465639", 
                   "profile_picture": "ttps://scontent.cdninstagram.com/hphotos-xap1/t51.2885-19/s150x150/12534147_1547250855586222_726330116_a_x.jpg", 
                   "username": "nihon_tarou"
               }, 
               "id": "1168922659837838042", 
               "text": "Wiiuかったぞー"
           }, 
           "comments": {
               "count": 0
           }, 
           "created_time": "1453566461", 
           "filter": "Normal", 
           "id": "1168922656817938508_2650465639", 
           "images": {
               "low_resolution": {
                   "height": 320, 
                   "url": "ttps://scontent.cdninstagram.com/hphotos-xpa1/t51.2885-15/s320x320/e35/12534130_230670640603143_771454513_n_x.jpg", 
                   "width": 320
               }, 
               "standard_resolution": {
                   "height": 640, 
                   "url": "ttps://scontent.cdninstagram.com/hphotos-xpa1/t51.2885-15/s640x640/sh0.08/e35/12534130_230670640603143_771454513_n_x.jpg", 
                   "width": 640
               }, 
               "thumbnail": {
                   "height": 150, 
                   "url": "ttps://scontent.cdninstagram.com/hphotos-xpa1/t51.2885-15/s150x150/e35/12534130_230670640603143_771454513_n_x.jpg", 
                   "width": 150
               }
           }, 
           "likes": {
               "count": 0
           }, 
           "link": "ttps://www.instagram.com/p/BA42PaRigBM_x/", 
           "location": null, 
           "tags": [], 
           "type": "image", 
           "user": {
               "full_name": "tarou", 
               "id": "2650465639", 
               "profile_picture": "ttps://scontent.cdninstagram.com/hphotos-xap1/t51.2885-19/s150x150/12534147_1547250855586222_726330116_a_x.jpg", 
               "username": "nihon_tarou"
           }, 
           "user_has_liked": false, 
           "users_in_photo": []
       }, 
       {
           "attribution": null, 
           "caption": {
               "created_time": "1453566414", 
               "from": {
                   "full_name": "tarou", 
                   "id": "2650465639", 
                   "profile_picture": "ttps://scontent.cdninstagram.com/hphotos-xap1/t51.2885-19/s150x150/12534147_1547250855586222_726330116_a_x.jpg", 
                   "username": "nihon_tarou"
               }, 
               "id": "1168922264583406250", 
               "text": "クリスマスセブンで半額1000円でケーキ買ってきた。デザートにしては多すぎた"
           }, 
           "comments": {
               "count": 0
           }, 
           "created_time": "1453566414", 
           "filter": "Normal", 
           "id": "1168922261731278909_2650465639", 
           "images": {
               "low_resolution": {
                   "height": 320, 
                   "url": "ttps://scontent.cdninstagram.com/hphotos-xfp1/t51.2885-15/s320x320/e35/12407315_1526484167649318_417599452_n_x.jpg", 
                   "width": 320
               }, 
               "standard_resolution": {
                   "height": 640, 
                   "url": "ttps://scontent.cdninstagram.com/hphotos-xfp1/t51.2885-15/s640x640/sh0.08/e35/12407315_1526484167649318_417599452_n_x.jpg", 
                   "width": 640
               }, 
               "thumbnail": {
                   "height": 150, 
                   "url": "ttps://scontent.cdninstagram.com/hphotos-xfp1/t51.2885-15/s150x150/e35/12407315_1526484167649318_417599452_n_x.jpg", 
                   "width": 150
               }
           }, 
           "likes": {
               "count": 0
           }, 
           "link": "ttps://www.instagram.com/p/BA42JqUigA9_x/", 
           "location": null, 
           "tags": [], 
           "type": "image", 
           "user": {
               "full_name": "tarou", 
               "id": "2650465639", 
               "profile_picture": "ttps://scontent.cdninstagram.com/hphotos-xap1/t51.2885-19/s150x150/12534147_1547250855586222_726330116_a_x.jpg", 
               "username": "nihon_tarou"
           }, 
           "user_has_liked": false, 
           "users_in_photo": []
       }
   ], 
   "meta": {
       "code": 200
   }, 
   "pagination": {}
}

検索api

ttps://api.instagram.com/v1/users/search?q=あいうえお&access_token=[access_token]

権限がないので以下のように表示される(2015/11/17からっぽい)

{"meta":{"error_type":"OAuthPermissionsException","code":400,"error_message":"This request requires scope=public_content, but this access token is not authorized with this scope. The user must re-authorize your application with scope=public_content to be granted this permissions."}}

この先は申請が必要だからテストで使うのは無理っぽいかな・・。

APIリクエスト回数限度

5000/時間

公式API限度ページ:https://www.instagram.com/developer/limits/

公式マニュアルページ

https://www.instagram.com/developer/

クローラーの規約

https://www.facebook.com/help/instagram/478745558852511/

自動装置などを使って本サービス上のあらゆるコンテンツ(ユーザーのプロフィールや写真を含みますが、これに限定されません)を巡回、収集、キャッシングしたり、これにアクセスすることを禁止しています(ただし、標準的な検索エンジンプロトコルまたはInstagramが明示的に認めている検索エンジンが使用する技術を用いる場合を除きます)。