Home  >  Article  >  php教程  >  如何给自己网站支持QQ登录

如何给自己网站支持QQ登录

WBOY
WBOYOriginal
2016-06-21 08:50:541203browse

 

1.打开open.qq.com   添加创建应用:-》输入常规的数据  你会看到对应的APP ID和KEY值,这是对你身份证的唯一的验证

2.打开 http://connect.qq.com/manage/  点击->添加网站->输入相关信息  这里比较特别注意的是,回调地址那里填上你域名就可以了以上申核需要一到两天时间,耐心等待。。。

3.打开http://wiki.opensns.qq.com/wiki/%E3%80%90QQ%E7%99%BB%E5%BD%95%E3%80%91%E7%BD%91%E7%AB%99%E6%8E%A5%E5%85%A5找到SDK库下载,我在这里下载是官方的php SDK包,如果你的虚拟空间file_get_contents不技持https,可以考虑用curl函数来替代,好多童鞋常常因为获取不到access_token也就是这个原因。任何一个包不是一气呵成了,还需你配置相关的配置,这个繁索的调试过程我就在这里展开谈了。说说原理->通过你的网站登陆QQ state和scope->获得access_token->再获得每个QQ唯一的身份ID  openid

4.在这里你调试成功后,获得ID后,还需和你当前网站帐号绑定,才能下次登陆的时候自动去识别你的相关绑定帐号内容 

常见问题:

1.Warning: session_start() [function.session-start]: open(/tmp\sess_s9b1ahi6vnvc0pfl2e0dcd0l10, O_RDWR) failed: 解决方法:No such file or directory (2) inD:\powhost\bbcarblog\web\test\qqSDK\comm\session.php on line 196 

找到sssion.php session_save_path  加上注释//,注释掉设置路径

2.Notice: file_get_contents() [function.file-get-contents]: Unable to find the wrapper "https" - did you forget to enable it when you configured PHP? inD:\powhost\bbcarblog\web\test\qqSDK\comm\utils.php on line 37 
解决方法:找到 Utils.php  function get_url_contents 函数内容直接用下面代码替代,因为file_get_content默认不支持访问https,如果要支持需配置php.ini,激活 php_openssl.dll 模块,这个大家百度配置一下便可
 

  1. $ch = curl_init();    
  2.     curl_setopt($ch, CURLOPT_URL,$url);    
  3.     curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);    
  4.     curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);    
  5.     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);    
  6.     $result = curl_exec($ch);    
  7.     return $result  



Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn