0
내가 Disqus에로의 OAuth를 사용하려고 할 때이 오류가 점점 계속 :Disqus에 OAuth를 잘못된 그랜트
$oauth2token_url = 'https://disqus.com/api/oauth/2.0/access_token/';
$redirect_uri = 'http://www.example.com/';
$clienttoken_post = array(
"grant_type" => 'authorization_code',
"client_id" => PVConfiguration::getConfiguration('disqus') -> public_key,
"client_secret" => PVConfiguration::getConfiguration('disqus') -> private_key,
"redirect_uri" => $redirect_uri,
"code" => $this -> registry -> get['code']
);
$curl = curl_init($oauth2token_url);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $clienttoken_post);
curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$json_response = curl_exec($curl);
curl_close($curl);
print_r($json_response);
또는이 - 예 2 :
{"error_description":"Invalid parameter: redirect_uri","error":"invalid_grant"}
내 코드 this- 예 1과 같다 :
$url = 'https://disqus.com/api/oauth/2.0/access_token/';
$fields = array(
'grant_type' => 'authorization_code',
'client_id' => PVConfiguration::getConfiguration('disqus') -> public_key,
'client_secret' => PVConfiguration::getConfiguration('disqus') -> private_key,
'redirect_uri' => 'http://www.example.com/',
//'scope' => 'read,write,email',
'code' => $this -> registry -> get['code'],
);
$fields_string = '';
//url-ify the data for the POST
foreach($fields as $key=>$value) { $fields_string .= $key.'='.$value.'&'; }
rtrim($fields_string, '&');
//open connection
$ch = curl_init();
//set the url, number of POST vars, POST data
curl_setopt($ch,CURLOPT_URL, $url);
curl_setopt($ch,CURLOPT_POST, count($fields));
curl_setopt($ch,CURLOPT_POSTFIELDS, $fields_string);
//execute post
$result = curl_exec($ch);
//close connection
curl_close($ch);
print_r($result);
exit();
누구든지 방향을 제시 할 수 있습니까?
인증 키가 괜찮습니까? – Mave
괜찮습니까? –
Disqus에서 제공 한 올바른 것입니까? 또한 redirect_uri를 생략하십시오. – Mave