Skip to content

Instantly share code, notes, and snippets.

@ProdigyView
Created January 21, 2014 00:58
Show Gist options
  • Save ProdigyView/8532388 to your computer and use it in GitHub Desktop.
Save ProdigyView/8532388 to your computer and use it in GitHub Desktop.
Disqus PHP OAuth
$oauth2token_url = 'https://disqus.com/api/oauth/2.0/access_token/';
$clienttoken_post = array(
"grant_type" => 'authorization_code',
"client_id" => PVConfiguration::getConfiguration('disqus') -> public_key,
"client_secret" => PVConfiguration::getConfiguration('disqus') -> private_key,
"redirect_uri" => 'http://'. HOST_DOMAIN .'/disqus/grant',
"code" => $_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);
$token = json_decode($json_response);
echo '<pre>';
print_r($token);
$disqus = new DisqusAPI(PVConfiguration::getConfiguration('disqus') -> private_key);
$user = $disqus-> users ->details(array('user' => $token -> user_id));
print_r($user);
exit();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment