2016-10-07 2 views
0

작동하지 대표자에 게시 곱슬 곱슬이 오류를 제공합니다PHP는 요청이 액세스 토큰에 코드를 변경

Error: { "status": 403, "message": "Forbidden" }

이 내 코드입니다 : 일반적으로 금지

$ch = curl_init(); 
curl_setopt($ch, CURLOPT_URL, $url); 
curl_setopt($ch, CURLOPT_POST, 1); 

    curl_setopt($ch,CURLOPT_POSTFIELDS,"grant_type=authorization_code&client_id=4853355452345362719&client_secret=deb78310995ec1cf00918a5e688e2148e6043bd640ab16f0f7ecd7543b4ac764&code=".$code); 

curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 

$result =curl_exec ($ch); 
curl_close($ch); 

print_r($result); 

답변

0

(403) 사용 권한 오류를 제안합니다. 원격 API가 전송중인 코드를 인식하지 못할 것입니다

1

먼저 액세스 토큰을 생성해야합니다. 이것은 다음과 같은 URL을 컬링 수행 할 수 있습니다 :이 매개 변수와 https://api.pinterest.com/v1/oauth/token : "https://api.pinterest.com/oauth?response_type=code&redirect_uri={$callBackUrl}&client_id={$clientId}&scope=read_public,write_public"

이 인증 코드를 반환합니다, 당신은 다음이 URL을 사용하여 토큰 액세스를 생성하려면이 옵션을 사용할 수 있습니다.

$url = "https://api.pinterest.com/v1/oauth/token"; 
$body = "grant_type=authorization_code&client_id={$clientId}&client_secret={$clientSecret}&code={$code}"; 
$ch = curl_init(); 

curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); 
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); 
curl_setopt($ch, CURLOPT_HEADER, false); 
curl_setopt($ch, CURLINFO_HEADER_OUT, 1); 
curl_setopt($ch, CURLOPT_POST, true); 
curl_setopt($ch, CURLOPT_URL, $url); 
curl_setopt($ch, CURLOPT_POSTFIELDS, $body); 

$content = curl_exec($ch); 
curl_close($ch); 
$data = json_decode($content, true); 
관련 문제