PHP实现第四方QQ微信扫码登陆,不接入qq互联以及微信开发者平台-其他-爱上资源吧
最新公告
  • 欢迎您光临爱上资源吧,本站秉承服务宗旨 履行“站长”责任,销售只是起点 服务永无止境!立即加入我们
  • PHP实现第四方QQ微信扫码登陆,不接入qq互联以及微信开发者平台-其他

    【推荐】2020最新稳赚项目,下载就送五元,首单带赚70元,→ → → 点击马上参与

    php实现不接入鹅厂官方接口用户微信qq扫码登陆的实现

    前言:想找一个整合工具,方便自己直接拿来用。找了半天,没找到(或许搜索关键字不对)。只能自己造个轮子出来了PS:微信是直接拿论坛大佬写好了的。
    目前也就整合了下QQ微信的扫码登陆。

    自己抓的QQ包以及整合了网上一些已经封装好了的代码
    具体如下:
    QQ:

     preg_match('/qrsig=(.*?);/',$arr['header'],$match);
    if($qrsig=$match[1])
    return array('code'=>200,'qrsig'=>$qrsig,'data'=>base64_encode($arr['body']));
    else
    return array('code'=>400,'msg'=>'二维码获取失败');
    }%0s[1];
    }
    if($pskey){
    if(isset($_GET['findpwd'])){
    $_SESSION['findpwd_qq']=$uin;
    }
    return array('code'=>200,'uin'=>$uin,'skey'=>'@'.$skey[1],'pskey'=>$pskey,'superkey'=>$superkey[1],'nick'=>$r[5]);
    }else{
    return array('code'=>201,'msg'=>'登录成功,获取相关信息失败!'.$r[2]);
    }
    }elseif($r[0]==65){
    return array('code'=>400,'msg'=>'二维码已失效。');
    }elseif($r[0]==66){
    return array('code'=>202,'msg'=>'二维码未失效。');
    }elseif($r[0]==67){
    return de);
    preg_match('/redirect_uri="(.*?)"/', $body, $url);
    if ($code[0] == '200') {
    
    $body = $this->curl($url[1]);
    if (strpos($body,'1203'))
    {
    $ret['code'] = 400;
    $ret['msg'] = "短时间内不能重复进行微信登陆";
    return $ret;
    } 
    preg_match('/(\d*?)<\/wxuin>/', $body, $wxuin);
    $ret['code'] = 200;
    $ret['data']['uin'] = $wxuin[1];
    $ret['data']['type'] = 'wx';
    $ret['msg'] = '登录成功';
    } else {
    $ret['code'] = 408;
    $ret['msg'] = '请使用手机微信扫码登录';
    }
    return $ret;
    }
    }

    为了方便跳用,这里我又封装了一个类
    动态传入QQ微信的类名字符串快速实例化

    Tencent类:

    《?php Class Tencent{ protected $path = __DIR__ . '/'; private $cl; /* * 动态传入QQ或WX字符串,自动转换对应的api类登录 */ public function __construct($type) { //注册自动加载函数 spl_autoload_register([$this,'Psr4Autoload']); //引入curl $this->cl = new $type();
        }
        public function Psr4Autoload($class)
        {
        $class_file = $this->path .'/'. $class . '.php';
        if (file_exists($class_file))
        {
            include "$class_file";
        }else{
            die('类文件'.$class_file .'不存在');
        }
        }
        public function QRcode()
        {
            return call_user_func([$this->cl,__FUNCTION__]);
        }
        public function ListenQR(...$args)
        {
            return call_user_func([$this->cl,__FUNCTION__],$args);
        }
        public function __call($name, $arguments)
        {
           call_user_func_array([$this->cl,$name],(array)$arguments);
        }
    }

    以及最后一个curl类:

    《?php class Curl_Api { public $ua = "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36"; public function get_curl($url,$post=0,$referer=0,$cookie=0,$header=0,$ua=0,$nobaody=0){ $ch = curl_init(); curl_setopt($ch, CURLOPT_URL,$url); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); $httpheader[] = "Accept: application/json"; $httpheader[] = "Accept-Encoding: gzip,deflate,sdch"; $httpheader[] = "Accept-Language: zh-CN,zh;q=0.8"; $httpheader[] = "Connection: keep-alive"; curl_setopt($ch, CURLOPT_HTTPHEADER, $httpheader); if($post){ curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $post); } if($header){ curl_setopt($ch, CURLOPT_HEADER, TRUE); } if($cookie){ curl_setopt($ch, CURLOPT_COOKIE, $cookie); } if($referer){ curl_setopt($ch, CURLOPT_REFERER, $referer); } if($ua){ curl_setopt($ch, CURLOPT_USERAGENT,$ua); }else{ curl_setopt($ch, CURLOPT_USERAGENT,$this->ua);
            }
            if($nobaody){
                curl_setopt($ch, CURLOPT_NOBODY,1);
     
            }
            curl_setopt($ch, CURLOPT_TIMEOUT, 10);
            curl_setopt($ch, CURLOPT_ENCODING, "gzip");
            curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
            $ret = curl_exec($ch);
            curl_close($ch);
            return $ret;
        }
        function curl($url, $paras = array()) {
            $ch = curl_init();
            curl_setopt($ch, CURLOPT_URL, $url);
            curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
            curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
            $httpheader[] = "Accept:*/*";
            $httpheader[] = "Accept-Encoding:gzip,deflate,sdch";
            $httpheader[] = "Accept-Language:zh-CN,zh;q=0.8";
            $httpheader[] = "Connection:close";
            curl_setopt($ch, CURLOPT_HTTPHEADER, $httpheader);
            if ($paras['ctime']) { // 连接超时
                curl_setopt($ch, CURLOPT_CONNECTTIMEOUT_MS, $paras['ctime']);
            }
            if ($paras['rtime']) { // 读取超时
                curl_setopt($ch, CURLOPT_TIMEOUT_MS, $paras['rtime']);
            }
            if ($paras['post']) {
                curl_setopt($ch, CURLOPT_POST, 1);
                curl_setopt($ch, CURLOPT_POSTFIELDS, $paras['post']);
            }
            if ($paras['header']) {
                curl_setopt($ch, CURLOPT_HEADER, true);
            }
            if ($paras['cookie']) {
                curl_setopt($ch, CURLOPT_COOKIE, $paras['cookie']);
            }
            if ($paras['refer']) {
                if ($paras['refer'] == 1) {
                    curl_setopt($ch, CURLOPT_REFERER, 'http://m.qzone.com/infocenter?g_f=');
                } else {
                    curl_setopt($ch, CURLOPT_REFERER, $paras['refer']);
                }
            }
            if ($paras['ua']) {
                curl_setopt($ch, CURLOPT_USERAGENT, $paras['ua']);
            } else {
                curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36");
            }
            if ($paras['nobody']) {
                curl_setopt($ch, CURLOPT_NOBODY, 1);
            }
            curl_setopt($ch, CURLOPT_ENCODING, "gzip");
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
            $ret = curl_exec($ch);
            curl_close($ch);
            return $ret;
        }
         public function get_curl_split($url){
            $ch = curl_init();
            curl_setopt($ch, CURLOPT_URL,$url);
            curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
            curl_setopt(%2件就好
    
    include "Lib/Tencent/Tencent.php";
    $wx = new Tencent("Wechat");
    $ret = $wx->QRcode();
    ?>
    
    
     
    
    
    

    ajax.php :

    《?php
    include "Lib/Tencent/Tencent.php";
    $wx = new Tencent("Wechat");
    //直接获取到uuid后,监听就好了
    $ret = $wx->ListenQR($_GET['uuid']);
    //var_dump($ret);
    echo json_encode($ret,true);exit;

    数据库用户表多一个qq和wxuin字段、用于保存用户绑定的QQ和微信
    上面那个仅仅只是个例子,可能写的不是很好。大佬勿喷
    有什么疑问可在帖子下方发表一下

    1. 本站所有资源来源于用户上传和网络,因此不包含技术服务请大家谅解!如有侵权请邮件联系客服!kuq@kuqshw.com
    2. 本站不保证所提供下载的资源的准确性、安全性和完整性,资源仅供下载学习之用!如有链接无法下载、失效或广告,请联系客服处理,有奖励!
    3. 您必须在下载后的24个小时之内,从您的电脑中彻底删除上述内容资源!如用于商业或者非法用途,与本站无关,一切后果请用户自负!
    4. 如果您也有好的资源或教程,您可以投稿发布,成功分享后有站币奖励和额外收入!

    爱上资源吧 » PHP实现第四方QQ微信扫码登陆,不接入qq互联以及微信开发者平台

    发表评论

    © 2015-2020 爱上资源吧 - 武汉类森科技有限公司 & LaySNS Theme. All rights reserved kuq@kuqshw.com

    本站所有资源均采集网络 如有侵权、不妥,请第一时间联系我们【kuq@kuqshw.com】删除。敬请谅解!

    XML地图 | 站长导航