|
本帖最后由 千帆开发王文才 于 2018-5-28 13:56 编辑
(1)如果有论坛的qq互联开发者账号,只需在qq互联平台 把千帆qq登录地址加到授权地址中。qq登录地址:http://xxx.com/clientapi/qqoauth.php.
(2)忘记了qq互联账号:
1.需要修改文件论坛根目录下的 /clientapi/qqoauth.php
下载文件:
qqoauth.zip
(2.13 KB, 下载次数: 735)
。
备份源文件,覆盖。
2.修改根目录的 connect.php 文件
直接编辑文件,添加代码:
代码:
//-----------edit by qianfan 2018-3-28--------------------------
if(isset( $_GET['state'] ) && isset( $_GET['code'] ) && $_GET['state'] == 'qianfanqqoauth'){
require './source/class/class_core.php';
$discuz = C::app();
$discuz->init();
$pre = DB::$db->tablepre;
$appid = DB::result_first("SELECT svalue FROM ".DB::table('common_setting')." WHERE skey = 'connectappid'");
$appkey = DB::result_first("SELECT svalue FROM ".DB::table('common_setting')." WHERE skey = 'connectappkey'");
$data = array(
'grant_type' => 'authorization_code',
'client_id' => $appid,
'client_secret' => $appkey,
'code' => $_GET['code'] ,
'redirect_uri' => 'http://'. $_SERVER['HTTP_HOST'] .'/connect.php?action=authorizationfinish',
);
$url = 'https://graph.qq.com/oauth2.0/token';
$ch = curl_init();
$url .= (strpos($url, '?') !== false ? '&' : '?') . http_build_query($data);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0);
$response = curl_exec($ch);
$headers = curl_getinfo($ch);
if(curl_errno($ch) > 0)
exit(0);
curl_close($ch);
$authorizationUrl = 'http://'. $_SERVER['HTTP_HOST'] .'/clientapi/qqoauth.php?action=authorizationfinish&resp='.$response;
header( 'Location:' . $authorizationUrl );
exit(0);
}
//--------end-----------------------------------------------------
|
|