标签:
QQ第三方授权登录步骤:
1、首先获取appid和appkey的值
2、设置配置文件必备参数json格式以文件方式被读取
3、在QQ第三方平台设置好回调地址
配置文件(inc.php)设置:
<?php die(‘forbidden‘); ?> {
"appid":"****",
"appkey":"***********",
"callback":"http://www.bookask.com:8080/?login-callback-QQ", 回调地址
"scope":"get_user_info,get_info", 获取数据类型
"errorReport":true, 错误返回
"storageType":"file", 数据类型
"host":"localhost", 主机名
"user":"root", 数据库名
"password":"root", 密码
"database":"test" 数据表
}
回调文件(callback.php)
<?php
require_once("qqConnectAPI.php");
$qc = new QC();
$access_token = strtolower($qc->qq_callback());
$openid = strtolower($qc->get_openid());
// 第三方登陆数据处理开始
$sql = "select * from `ub01` where ub01004 = ‘$openid‘";
$chek = _selectone($sql) ? _selectone($sql) : array();
if(!empty($chek)){
$_SESSION[‘uid‘]=$res[‘ua01001‘];
header("Location:?");
}else{
$arr[‘ua01998‘] = time();
$arr[‘ua01005‘] = 4;
$arr[‘guid‘] = UUID();
$id = _inserttable(‘ua01‘,$arr,true);
if($id){
$brr[‘ua01001‘] = $id;
$brr[‘ub01003‘] = 4;
$brr[‘ub01004‘] = $openid;
$arr[‘ub01998‘] = time();
$brr[‘guid‘] = UUID();
$sid = _inserttable(‘ub01‘,$arr,true);
if($sid){
$sql = "select * from `ub01` where ub01001 = ‘$sid‘";
$cheks = _selectone($sql) ? _selectone($sql) : array();
if(!empty($cheks)){
$_SESSION[‘uid‘]=$res[‘ua01001‘];
header("Location:?");
}
}
}
}
// 第三方登陆数据处理结束
标签:
原文地址:http://www.cnblogs.com/520fyl/p/5405342.html