Instagram/api
提供: 初心者エンジニアの簡易メモ
目次
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/
- regist new clinetsからアプリケーション作成
- Client ID と Client Secret を取得できる
- "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
自身の投稿画像を取得
https://api.instagram.com/v1/users/self/media/recent/?access_token=[access_token]
{
"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/
