ppypp伦理天堂,91手机在线视频,免费在线观看黄色毛片,夜夜穞天天穞狠狠穞AV美女按摩

聯(lián)系官方銷(xiāo)售客服

1835022288

028-61286886

投訴 已解決 小程序授權(quán)登入和微信小程序登入除了請(qǐng)求接口和不同外其他的都是 5 0

QQ小程序授權(quán)登入和微信小程序登入除了請(qǐng)求接口和APPid不同外其他的都是一樣的,我把微信小程序的API登入接口改成QQ的后就可以直接登入了,請(qǐng)問(wèn)怎么在增加個(gè)登入接口,讓微信小程序登入和QQ小程序同時(shí)能用

下面這個(gè)是我把微信的請(qǐng)求接口和改成QQ了

  // 小程序登錄
    public function xcx() {

        if (IS_POST) {

            $json = json_decode($_POST['json'], true);
            if (!$json) {
                $this->_json(0, 'POST數(shù)據(jù)解析失敗');
            } elseif (!$_POST['js_code']) {
                $this->_json(0, 'js_code數(shù)據(jù)獲取失敗');
            }

            $url = "https://api.q.qq.com/sns/jscode2session?appid=" . $this->weixin['xcx']['appid'] . "&secret=".$this->weixin['xcx']['appsecret']."&js_code=". $_POST['js_code']."&grant_type=authorization_code";
            $token = json_decode(dr_catcher_data($url), true);
            if (!$token) {
                $this->_json(0, 'jscode2session獲取失敗');
            } elseif (isset($token['errcode']) && $token['errcode']) {
                $this->_json(0, 'jscode2session錯(cuò)誤代碼('.$token['errcode'].'):'.$token['errmsg'].' appid='.$this->weixin['xcx']['appid'].'&secret='.$this->weixin['xcx']['appsecret'].'');
            } elseif (!$token['openid']) {
                $this->_json(0, 'jscode2session:openid獲取失敗');
            }

            $rt = \Phpcmf\Service::M('member')->insert_oauth(0, 'login', [
                'oid' => $token['openid'],
                'oauth' => 'wxxcx',
                'avatar' => $json['avatarUrl'],
                'unionid' => (string)$token['unionid'],
                'nickname' => dr_emoji2html($json['nickName']),
                'expire_at' => SYS_TIME,
                'access_token' => $token['session_key'],
                'refresh_token' => '',
            ]);
            if (!$rt['code']) {
                $this->_json(0, $rt['msg']);
            }

            $oauth = \Phpcmf\Service::M()->table('member_oauth')->get($rt['code']);
            if (!$oauth) {
                $this->_json(0, '服務(wù)端儲(chǔ)存用戶(hù)失敗');
            } elseif ($oauth['uid']) {
                $rt = \Phpcmf\Service::M('member')->login_uid($oauth, $oauth['uid']);
                if (!$rt['code']) {
                    $this->_json(0, $rt['msg']);
                }
                $this->_json(1, 'login', $rt['data']);
            }

            if ($this->weixin['xcx']['login']) {
                // 直接登錄
                $rt = \Phpcmf\Service::M('member')->register_oauth(0, $oauth);
                if ($rt['code']) {
                    // 登錄成功
                    $this->_json(1, 'login', $rt['data']);
                } else {
                    $this->_json(0, $rt['msg']);
                }
            } else {
                // 提示注冊(cè)
                $oauth['nickname'] = dr_html2emoji($oauth['nickname']);
                $this->_json(1, 'register', $oauth);
            }

        } else {
            $this->_json(0, '非POST提交');
        }

        exit;
    }

    // 小程序綁定賬號(hào)
    public function xcx_bang() {

        if (IS_POST) {

            $oid = (int)\Phpcmf\Service::L('Input')->post('oid');
            $post = \Phpcmf\Service::L('Input')->post('data', true);
            if (!$post) {
                $this->_json(0, 'POST數(shù)據(jù)解析失敗');
            } elseif (!$oid) {
                $this->_json(0, '小程序OpenId為空');
            }

            $oauth = \Phpcmf\Service::M()->table('member_oauth')->get($oid);
            if (!$oauth) {
                $this->_json(0, '服務(wù)端用戶(hù)不存在');
            } elseif ($oauth['uid']) {
                $rt = \Phpcmf\Service::M('member')->login_uid($oauth, $oauth['uid']);
                if (!$rt['code']) {
                    $this->_json(0, $rt['msg']);
                }
                $this->_json(1, 'ok', $rt['data']);
            }

            // 登錄綁定
            if (empty($post['username']) || empty($post['password'])) {
                $this->_json(0, dr_lang('賬號(hào)或密碼必須填寫(xiě)'));
            } else {
                $rt = \Phpcmf\Service::M('member')->login($post['username'], $post['password']);
                if ($rt['code']) {
                    // 登錄成功
                    \Phpcmf\Service::M()->db->table('member_oauth')->where('id', $oid)->update(['uid' => $rt['data']['member']['id']]);
                    $this->_json(1, 'ok', $rt['data']);
                } else {
                    $this->_json(0, $rt['msg']);
                }
            }

        } else {
            $this->_json(0, '非POST提交');
        }
    }


    // 小程序注冊(cè)賬號(hào)
    public function xcx_reg() {

        if (IS_POST) {

            $oid = (int)\Phpcmf\Service::L('Input')->post('oid');
            $post = \Phpcmf\Service::L('Input')->post('data', true);
            if (!$post) {
                $this->_json(0, 'POST數(shù)據(jù)解析失敗');
            } elseif (!$oid) {
                $this->_json(0, '小程序OpenId為空');
            }

            $oauth = \Phpcmf\Service::M()->table('member_oauth')->get($oid);
            if (!$oauth) {
                $this->_json(0, '服務(wù)端用戶(hù)不存在');
            } elseif ($oauth['uid']) {
                $rt = \Phpcmf\Service::M('member')->login_uid($oauth, $oauth['uid']);
                if (!$rt['code']) {
                    $this->_json(0, $rt['msg']);
                }
                $this->_json(1, 'ok', $rt['data']);
            }

            // 注冊(cè)

            if (empty($post['password'])) {
                $this->_json(0, dr_lang('密碼必須填寫(xiě)'), ['field' => 'password']);
            } elseif ($post['password'] != $post['password2']) {
                $this->_json(0, dr_lang('確認(rèn)密碼不一致'), ['field' => 'password2']);
            } else {
                $rt = \Phpcmf\Service::M('member')->register_oauth_bang($oauth, 0, [
                    'username' => (string)$post['username'],
                    'phone' => (string)$post['phone'],
                    'email' => (string)$post['email'],
                    'password' => dr_safe_password($post['password']),
                    'name' => dr_safe_replace($post['name']),
                ]);
                if ($rt['code']) {
                    // 注冊(cè)綁定成功
                    $this->_json(1, 'ok', $rt['data']);
                } else {
                    $this->_json(0, $rt['msg'], ['field' => $rt['data']['field']]);
                }
            }

        } else {
            $this->_json(0, '非POST提交');
        }
    }

插件版權(quán):官方插件
插件名稱(chēng):API
解決方案