千帆云

 找回密码
 立即注册

QQ登录

只需一步,快速开始

返回列表 回复
查看: 4585|回复: 0
打印 上一主题 下一主题

qq互联新版方案,暂未使用,只是保存下

[复制链接]

7

主题

13

帖子

0

积分

认证版主

Rank: 7Rank: 7Rank: 7

积分
0
跳转到指定楼层
楼主
发表于 2016-11-22 15:00:58 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式 | 来自江苏
本帖最后由 千帆开发王文才 于 2016-11-24 16:21 编辑

Dz需要自定义修改,仅限获取了unionid调用权限的开发者账号
修改之前,注意备份《《《
以discuzX3.2源码为例
1.修改文件
DZ_X3.2\source\plugin\qqconnect\connect\connect_login.php
大概142行起需要增加代码


  1. //----------------------------2016-11-22新增--------------------------------------------
  2.         if($conuintoken)
  3.         {
  4.                 $requestUrl = 'https://graph.qq.com/oauth2.0/me?access_token='.$conuintoken.'&unionid=1';
  5.                 $res = @dfsockopen($requestUrl, 0,array(), '', 0, '', 1, 1, 'URLENCODE', 1, 0);
  6.                 if(strpos($res, "callback") === false)
  7.                 {
  8.                         $unionid = '';
  9.                 }else{
  10.                         $lpos = strpos($res, "(");
  11.                         $rpos = strrpos($res, ")");
  12.                         $res = substr($res, $lpos + 1, $rpos - $lpos - 1);
  13.                         $res = json_decode($res);
  14.                         $unionid = $res->unionid;
  15.                 }
  16.                 $response['unionid'] = $unionid;

  17.         }

  18.         if($conopenid && $response['unionid'])
  19.         {
  20.                 $uid = DB::result_first( "SELECT uid FROM %t WHERE conopenid = %s LIMIT 1", array('common_member_connect', $conopenid) );
  21.                 $uid1 = DB::result_first( "SELECT uid FROM %t WHERE unionid = %s AND weibotype = %s LIMIT 1", array('thirdbind', $response['unionid'] , 'qq' ) );
  22.                 // 如果app先绑定qq,且unionid已注册,此时以论坛为准,openid取不到数据,需要修改openid为论坛的openid
  23.                 if(!$uid && $uid1)
  24.                 {
  25.                         if($appopenid = DB::result_first( "SELECT conopenid FROM %t WHERE uid = %s LIMIT 1", array('common_member_connect', $uid1) ))
  26.                         {
  27.                                 C::t('common_member_connect')->update($uid1,array('conopenid'=>$conopenid));
  28.                         }
  29.                 }
  30.                 // 如果app先绑定qq,且unionid未注册,   这个不能做关联  phonebind是没记录的 论坛的openid是移动端appid的openid
  31.                 if(!$uid && !$uid1)
  32.                 {
  33.                         //已登录用户绑定unionid
  34.                         //先登录app,自行绑定unionid,再登陆论坛才行,
  35.                         if($_G['uid'])
  36.                         {
  37.                                 $auser = getuserbyuid($_G['uid']);
  38.                                 $nickname = $auser['username'] ? $auser['username'] : '';
  39.                                 $params = array(
  40.                                                 'uid'=>$_G['uid'],
  41.                                                 'weibotype'=>'qq',
  42.                                                 'nickname'=>$nickname,
  43.                                                 'openid'=>$conopenid,
  44.                                                 'unionid'=>$response['unionid'],
  45.                                                 'dateline'=>time()
  46.                                 );
  47.                                 DB::insert('thirdbind',$params,true);
  48.                         }
  49.                 }
  50.                 //如果论坛先绑定qq,或者都没绑定的话,那unionid需要注册,其他正常进行。app登陆时做好兼容只查unionid
  51.                 if($uid)
  52.                 {
  53.                         $qqunionid = DB::result_first( "SELECT unionid FROM %t WHERE uid = %s AND weibotype = %s LIMIT 1", array('thirdbind', $uid , 'qq' ) );
  54.                         if($qqunionid == false)
  55.                         {
  56.                                 //没记录,需插入第三方绑定数据
  57.                                 $auser = getuserbyuid($uid);
  58.                                 $nickname = $auser['username'] ? $auser['username'] : '';
  59.                                 $params = array(
  60.                                                 'uid'=>$uid,
  61.                                                 'weibotype'=>'qq',
  62.                                                 'nickname'=>$nickname,
  63.                                                 'openid'=>$conopenid,
  64.                                                 'unionid'=>$response['unionid'],
  65.                                                 'dateline'=>time()
  66.                                 );
  67.                                 DB::insert('thirdbind',$params,true);
  68.                         }elseif($qqunionid == '')
  69.                         {
  70.                                 //有记录,但未注册unionid
  71.                                 DB::update("thirdbind", array("unionid" => $response['unionid']), array('uid'=>$uid, 'weibotype'=>'qq'));
  72.                         }
  73.                 }
  74.         }
复制代码


2.需要更新qianfan插件
qianfan/protected/controllers/MemberController.php
文件 MemberController.zip (13.08 KB, 下载次数: 433)










分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 支持支持 反对反对
回复

使用道具 举报

高级模式
B Color Image Link Quote Code Smilies |上传

本版积分规则

QQ|Archiver|手机版|小黑屋|千帆移动开放平台  

GMT+8, 2024-5-19 06:31

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表