QQ互联登录PHP-SDK,(-1)invalid openid错误—解决方法
随风飘扬 学习 2015年10月04日12:09 4662
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();
虎oy_e_泰jyaz克xd新rzdkd闻qel网qr版权所有,请勿未授权转载!!!
注意几点:
虎nvx泰gr克uonmi新helbo闻va网djk_k版权所有,请勿未授权转载!!!
1、定义$qc 时,记得使用new 关键字
虎hlws泰tslj克d新ykt闻_网cfp版权所有,请勿未授权转载!!!
2、要定义两次$qc= new qc(),第一次用于获取正确的access_token 和openid,第二次用于保证正确传输access_token和openid以保证api的使用
虎k泰wy克zxy新j闻wy_bp网r版权所有,请勿未授权转载!!!
3、【顺序】一定要先获取access_token(即先使用qq_callback()方法),再获取openid(get_openid()方法),否则错误,作者本人因为偶然写反了顺序,花了1小时才找到错误。。。
虎vvla泰swnox克gwp新um_cr闻kp网loqp版权所有,请勿未授权转载!!!
4、【代码位置】,为了尽量减少未知的错误,尽量保证 上述代码在整个php代码执行流程中,保持在顶端先执行(尤其注意因require等方式包含进来的代码),
虎qrqtc泰ek克jzex新x闻piknu网w版权所有,请勿未授权转载!!!
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