我在其他帖子中看到了这个答案,但它们已经过时了,我知道IG自此更新了它的API。Instagram API访问令牌请求失败
我跟着他们的开发者文档,但似乎无法从我的本地主机发出请求。
$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
上面的代码是我如何提出我的请求,但我得到以下错误。
{"code": 400, "error_type": "OAuthException", "error_message": "Matching code was not found or was already used."}
我有残疾隐含的OAuth,设置应用程序是非常基本的,所有的设置将我的个人网站暂时的,作为应用在沙盒模式反正。
'http:// localhost /'是一个真实的URL,但它不是公开的。我允许自己稍微编辑一下你的答案。 – DanFromGermany