2016-12-09 4 views
0

다른 게시물에서이 답변을 보았습니다.하지만 상당히 오래된 것으로 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 

위의 코드는 요청하는 방법이지만 다음과 같은 오류가 발생합니다. 나는 장애인 암시의 OAuth를

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

는 설정 앱에서 모든 설정 앱이 어쨌든 샌드 박스 모드에서와 같이 당분간 내 개인 사이트에가는, 아주 기본적인 것입니다.

답변

0

새로운 토큰을 요청할 때마다 Instagram 계정을 로그 아웃해야했습니다.

0

redirect_urilocalhost이 아닌 공개 URL 주소를 가리켜 야합니다.

+0

'http : // localhost /'는 실제 URL이지만 공개되지는 않습니다. 나는 너 자신의 대답을 조금 편집 할 수 있었다. – DanFromGermany

관련 문제