qq登陆inc.php,JTBC(php) 版 QQ 一键登录实现过程

0c3e1f26b517a4d1c2584dffe05e673f.jpg%0A

1、下载 qq 互联 php 版开发包  http://wiki.open.qq.com/wiki/website/SDK下载

2、把文件夹 API、install和文件index.php 复制到 expansion 文件加下。

3、地址栏输入" 域名/expansion/qq/" 按提示执行相关配置。回调地址:passport/qqdenglu.php

4、

require_once("../expansion/qq/API/qqConnectAPI.php");

require('../common/incfiles/function.inc.php');

define('APP_NAME', 'jtbc_');

define('COOKIES_PATH', '/');

$qc = new QC();

$access_token = $qc->qq_callback();

$openid = $qc->get_openid();

$qcc = new QC($access_token,$openid);

$arr = $qcc->get_user_info();

if (!is_null($arr))

{

$access_token = md5($access_token);

$_SESSION[APP_NAME . 'access_token'] = $access_token;

$dialog_url = "=" . $arr["nickname"] . "&sex=" . $arr["gender"] . "&openid=" . $openid . "&access_token=" . $access_token ;

echo '';

echo("");

exit();

}

else

{

echo "";

}

?>

5、加处理函数passport/common/incfiles/interface_config.inc.php, 注意:加处跳转代码,请自行添加。

function jtbc_cms_interface_qq_denglu()

{

$sex = ii_unescape(ii_get_safecode($_GET['sex']));

$name = ii_unescape(ii_get_safecode($_GET['name']));

$openid = ii_get_safecode($_GET['openid']);

$access_token = ii_unescape(ii_get_safecode($_GET['access_token']));

if $access_token != $_SESSION[APP_NAME . 'access_token'] die('forbidden');

global $conn;

global $ndatabase, $nidfield, $nfpre;

$zucehao = $openid;

$zucema = $access_token;

if (ap_check_isuser($zucehao) == 0)

{

$tsqlstr = "insert into $ndatabase (

" . ii_cfname('username') . ",

" . ii_cfname('password') . ",

" . ii_cfname('name') . ",

" . ii_cfname('time') . "

) values (

'$zucehao',

'$zucema',

'$name',

'" . ii_now() . "'

)";

$trs = ii_conn_query($tsqlstr, $conn);

}

else

{

$tsqlstr = "update $ndatabase set " . ii_cfname('password') . "='$zucema' ," . ii_cfname('pretime') . "=" . ii_cfname('lasttime') . "," . ii_cfname('lasttime') . "='" . ii_now() . "' where " . ii_cfname('username') . "='$zucehao'";

$trs = ii_conn_query($tsqlstr, $conn);

}

if ($trs)

{

setcookie(APP_NAME . 'user[username]', $zucehao, 0, COOKIES_PATH);

setcookie(APP_NAME . 'user[password]', $access_token, 0, COOKIES_PATH);

$_SESSION[APP_NAME . 'username'] = $openid;

header('location:http://域名');

}

else

{

echo "";

}

}

6、添加登陆链接文件 expansion/qq/login.php

require_once("API/qqConnectAPI.php");

$qc = new QC();

$qc->qq_login();

7、删除 expansion/qq/ 下 install 文件夹 index.php 文件

来源:http://qihui.name/bian_cheng/96.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值