duanpa1980 2016-12-09 22: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 15:30
    关注

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

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

报告相同问题?

悬赏问题

  • ¥15 关于#java#的问题:找一份能快速看完mooc视频的代码
  • ¥15 这种微信登录授权 谁可以做啊
  • ¥15 请问我该如何添加自己的数据去运行蚁群算法代码
  • ¥20 用HslCommunication 连接欧姆龙 plc有时会连接失败。报异常为“未知错误”
  • ¥15 网络设备配置与管理这个该怎么弄
  • ¥20 机器学习能否像多层线性模型一样处理嵌套数据
  • ¥20 西门子S7-Graph,S7-300,梯形图
  • ¥50 用易语言http 访问不了网页
  • ¥50 safari浏览器fetch提交数据后数据丢失问题
  • ¥15 matlab不知道怎么改,求解答!!