Skip to content

Commit

Permalink
添加授权登录
Browse files Browse the repository at this point in the history
  • Loading branch information
fooleap committed Mar 10, 2018
1 parent c615c07 commit 747b3f7
Show file tree
Hide file tree
Showing 30 changed files with 13,534 additions and 3,149 deletions.
8 changes: 5 additions & 3 deletions api/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* 配置文件
*
* @author fooleap <[email protected]>
* @version 2017-07-27 20:33:28
* @version 2018-03-10 13:19:05
* @link https://github.com/fooleap/disqus-php-api
*
*/
Expand All @@ -13,6 +13,8 @@
* Disqus 设置
*
* DISQUS_PUBKEY Disqus 公钥,无需修改
* PUBLIC_KEY Disqus APP 公钥,在 https://disqus.com/api/applications/ 申请注册后获得
* SECRET_KEY Disqus APP 私钥,在 https://disqus.com/api/applications/ 申请注册后获得
* DISQUS_USERNAME Disqus 用户名
* DISQUS_EMAIL Disqus 注册邮箱,重要
* DISQUS_PASSWORD Disqus 密码,重要
Expand All @@ -27,6 +29,8 @@
*/

define('DISQUS_PUBKEY', 'E8Uh5l5fHZ6gD8U3KycjAIAk46f68Zw7C6eW8WSjZvCLXebZ7p0r1yrYDrLilk2F');
define('PUBLIC_KEY', '');
define('SECRET_KEY', '');
define('DISQUS_USERNAME', '');
define('DISQUS_EMAIL', '');
define('DISQUS_PASSWORD', '');
Expand All @@ -51,13 +55,11 @@
* 图片设置
*
* GRAVATAR_CDN Gravatar 头像 CDN
* GRAVATAR_DEFAULT 默认头像 URL
* EMOJI_PATH Emoji 表情 PNG 资源路径
*
*/

define('GRAVATAR_CDN', '//cn.gravatar.com/avatar/');
define('GRAVATAR_DEFAULT', 'https://a.disquscdn.com/images/noavatar92.png');
define('EMOJI_PATH', 'https://assets-cdn.github.com/images/icons/emoji/unicode/');

/*
Expand Down
2 changes: 1 addition & 1 deletion api/count.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

$links = '&thread=link:'.$website.preg_replace('/,/i','&thread=link:'.$website, $_GET['links']);

$fields_data = array(
$fields_data = (object) array(
'api_key' => DISQUS_PUBKEY,
'forum' => DISQUS_SHORTNAME,
'limit' => 100
Expand Down
5 changes: 2 additions & 3 deletions api/createthread.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,14 @@
* @param identifier identifier
*
* @author fooleap <[email protected]>
* @version 2017-07-01 16:13:50
* @version 2018-03-10 13:59:51
* @link https://github.com/fooleap/disqus-php-api
*
*/
namespace Emojione;
require_once('init.php');
$curl_url = '/api/3.0/threads/create.json';
$post_data = array(
'api_key' => DISQUS_PUBKEY,
$post_data = (object) array(
'forum' => DISQUS_SHORTNAME,
'identifier' => $_POST['identifier'],
'message' => $_POST['message'],
Expand Down
14 changes: 13 additions & 1 deletion dist/eac.min.json → api/eac.min.php

Large diffs are not rendered by default.

36 changes: 12 additions & 24 deletions api/getcomments.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
* @param cursor 当前评论位置
*
* @author fooleap <[email protected]>
* @version 2017-11-13 17:03:14
* @version 2018-03-10 14:00:54
* @link https://github.com/fooleap/disqus-php-api
*
*/
namespace Emojione;
require_once('init.php');

$fields_data = array(
$fields_data = (object) array(
'api_key' => DISQUS_PUBKEY,
'cursor' => $_GET['cursor'],
'limit' => 50,
Expand All @@ -25,7 +25,7 @@
$curl_url = '/api/3.0/threads/listPostsThreaded?'.http_build_query($fields_data);
$data = curl_get($curl_url);

$fields_data = array(
$fields_data = (object) array(
'api_key' => DISQUS_PUBKEY,
'forum' => DISQUS_SHORTNAME,
'thread' => 'link:'.$website.$_GET['link']
Expand All @@ -40,26 +40,14 @@
}
}

//if( isset($detail -> response -> ipAddress)){
if( strpos($session, 'session') !== false ){
$isAuth = true;
} else {
$isAuth = false;
}

if($data -> code == 0 ){
$output = array(
'auth' => $isAuth,
'code' => $detail -> code,
'cursor' => $data -> cursor,
'link' => 'https://disqus.com/home/discussion/'.DISQUS_SHORTNAME.'/'.$detail -> response -> slug.'/?l=zh',
'posts' => $detail -> response -> posts,
'response' => $posts,
'thread' => $detail -> response -> id
);
} else {
$output = $data;
$output -> auth = $isAuth;
}
$output = $data -> code == 0 ? (object) array(
'code' => $detail -> code,
'cursor' => $data -> cursor,
'forum' => $forum_data -> forum,
'link' => 'https://disqus.com/home/discussion/'.DISQUS_SHORTNAME.'/'.$detail -> response -> slug.'/?l=zh',
'posts' => $detail -> response -> posts,
'response' => $posts,
'thread' => $detail -> response -> id
) : $data;

print_r(json_encode($output));
Loading

0 comments on commit 747b3f7

Please sign in to comment.