1、首先在http://connect.qq.com 申请APP ID和KEY
2、然后现在SDK http://wiki.connect.qq.com/sdk下载
3、在QQ互联中心填写网站基本信息,回调地址填写SDK中的/example/oauth/callback.php 即可
4、网站地址可新建个专门验证的文件或目录,并在界面上添加QQ登录按钮
5、把SDK上传到网站,并访问install安装,填写APP ID 和 KEY 回调地址信息,回调地址要与互联中心填写的一致
6、报错没开启CURL和SSL解决办法:修改 URL.class.php 中的 get_contents 方法为:
:
public function get_contents($url){
$ch = curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_URL, $url);
$response = curl_exec($ch);
curl_close($ch);
if(empty($response)){
$this->error->showError("50001");
}
return $response;
}
7.添加callback.php内容
$acs = $qc->qq_callback();
$oid = $qc->get_openid();
$qc = new QC($acs,$oid);
$uinfo = $qc->get_user_info();
echo '<meta charset="UTF-8">';
echo "<p>";
echo "Gender:".$uinfo["gender"];
echo "</p>";
echo "<p>";
echo "NickName:".$uinfo["nickname"];
echo "</p>";
echo "<p>";
echo "<p>";
echo "<img src=\"".$uinfo['figureurl_qq_2']."\">";
echo "<p>";
8.测试登录能显示昵称和头像即可提交审核