QQ互联登录PHP-SDK,(-1)invalid openid错误—解决方法
随风飘扬 学习 2015年10月04日12:09 4114
QQ互联登录PHP-SDK,(-1)invalid openid错误—解决方法,问题现象是:部署了P
QQ互联登录PHP-SDK,(-1)invalid openid错误—解决方法,问题现象是:部署了PHP-SDK之后,出现有时能登录,有时不能登录的情况,错误提示是:-1 client request's parameters are invalid, invalid openid 网上找过很多方法,测试了各种调试两天,终于貌似找到了解决方法: 在 callback.php页面 请按顺序放置以下几行代码 require_once("API/qqConnectAPI.php"); $qc = new QC(); $acs = $qc->qq_callback(); $oid = $qc->get_openid(); $qc = new QC($acs,$oid); $uinfo = $qc->get_user_info();
虎ajr泰ai克oha_s新s闻s网jgx版权所有,请勿未授权转载!!!
注意几点:
虎yodx_泰gnx_克j新crn闻zjj网eycwy版权所有,请勿未授权转载!!!
1、定义$qc 时,记得使用new 关键字
虎_efqt泰udll克yw新yh闻alrl网hbx版权所有,请勿未授权转载!!!
2、要定义两次$qc= new qc(),第一次用于获取正确的access_token 和openid,第二次用于保证正确传输access_token和openid以保证api的使用
虎f泰r克ejnji新rgb闻dfqk网zke版权所有,请勿未授权转载!!!
3、【顺序】一定要先获取access_token(即先使用qq_callback()方法),再获取openid(get_openid()方法),否则错误,作者本人因为偶然写反了顺序,花了1小时才找到错误。。。
虎s泰_aqay克ra新v闻evo网_vzii版权所有,请勿未授权转载!!!
4、【代码位置】,为了尽量减少未知的错误,尽量保证 上述代码在整个php代码执行流程中,保持在顶端先执行(尤其注意因require等方式包含进来的代码),
虎hda泰n克taiqx新_y闻bejx网sdz版权所有,请勿未授权转载!!!
5、【变量传递】作者推荐:在第一次new QC()之后,立即获取access_token和openid,并立即重新使用获取到的access_token和openid来重新定义QC()类(见上述代码示例),以防止变量丢失或被覆盖
Statement: all articles / drawings reproduced on this website are for the purpose of transmitting more information and facilitating discussion, which does not mean that the website, the host and the organizer agree with their opinions or confirm the authenticity of their contents. The contents of the articles are for reference only. If the rights of the original author are violated, please contact the website administrator.
Comment list
-
No data