dtyyrt4545 2014-01-22 20:56
浏览 41

too long

I'm trying to create a login system using disqus authentication, but even when I'm following their tutorials exactly as they say, the user access their system, but I don't get any data... Everything return as null...

    <?php

//This is a all-in-one example of API authentication and making API calls using OAuth
//More information on using OAuth with Disqus can be found here: http://disqus.com/api/docs/auth/

//error_reporting(E_ALL ^ E_NOTICE) ;

$PUBLIC_KEY = "mypk";
$SECRET_KEY = "mysk";
$redirect = "returning addr";

$endpoint = 'https://disqus.com/api/oauth/2.0/authorize?';
$endpoint = 'https://disqus.com/api/oauth/2.0/authorize/?';
$client_id = $PUBLIC_KEY;
$scope = 'read,write';
$response_type = 'code';

$auth_url = $endpoint.'&client_id='.$client_id.'&scope='.$scope.'&response_type='.$response_type.'&redirect_uri='.$redirect;

echo $auth_url;

// Trigger the initial authentication call to receive a code
echo "<h3>Trigger authentication -> <a href='".$auth_url."'>OAuth</a></h3>";


// Get the code to request access
$CODE = $_GET['code'];

if($CODE){

echo '<br>' . $CODE . '<br>';

// Build the URL and request the authentication token
extract($_POST);

$authorize = "authorization_code";

$url = 'https://disqus.com/api/oauth/2.0/access_token/?';
$fields = array(
  'grant_type'=>urlencode($authorize),
  'client_id'=>urlencode($PUBLIC_KEY),
  'client_secret'=>urlencode($SECRET_KEY),
  'redirect_uri'=>urlencode($redirect),
  'code'=>urlencode($CODE)
);

//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);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);

//execute post
$data = curl_exec($ch);

print_r($data);

//close connection
curl_close($ch);
}
?>

And yes, I tried to find something here that would help me...

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 HLs设计手写数字识别程序编译通不过
    • ¥15 Stata外部命令安装问题求帮助!
    • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
    • ¥15 TYPCE母转母,插入认方向
    • ¥15 如何用python向钉钉机器人发送可以放大的图片?
    • ¥15 matlab(相关搜索:紧聚焦)
    • ¥15 基于51单片机的厨房煤气泄露检测报警系统设计
    • ¥15 Arduino无法同时连接多个hx711模块,如何解决?
    • ¥50 需求一个up主付费课程
    • ¥20 模型在y分布之外的数据上预测能力不好如何解决