[英]Instagram API access token request fail
我在其他帖子中看到了有關此問題的答案,但它們已經過時了,我知道IG從那時起就對其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,該應用程序的設置非常基本,所有設置暫時都轉到我的個人網站,因為該應用程序始終處於沙盒模式。
redirect_uri
應該指向一個公共URL地址,而不是localhost
。
事實證明,每次我想要請求新令牌時,我只需要注銷自己的Instagram帳戶。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.