duanpa1980 2016-12-09 14:56
浏览 73
已采纳

Instagram API访问令牌请求失败

I seen answers for this in other posts but they are quite outdated and I know IG has updated their api since.

I followed their developer documentation but can not seem to make a request from my localhost.

$fields = array(
   'client_id'     => 'a2xxxxxxxxxxxxxxxxxxxxxxxxxxxxed',
   'client_secret' => '3bxxxxxxxxxxxxxxxxxxxxxxxxxxxxx8f',
   'grant_type'    => 'authorization_code',
   'redirect_uri'  => 'http://localhost:8000/',
   'code'          => 'code'
);

$url = 'https://api.instagram.com/oauth/access_token';

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 20);
curl_setopt($ch, CURLOPT_POST,true); 
curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);
$result = curl_exec($ch);
curl_close($ch); 
print $result; //your token

The above code is how I am making my request but I get the following error.

{"code": 400, "error_type": "OAuthException", "error_message": "Matching code was not found or was already used."}

I have disabled implicit oAuth, the app set up is pretty basic, with all the settings going to my personal site for the time being as the app is in sandbox mode anyway.

  • 写回答

2条回答 默认 最新

  • dongzhong5573 2016-12-14 07:30
    关注

    Turns out, I just had to logout of my Instagram account each time I wanted to request a new token.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)
编辑
预览

报告相同问题?

手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部