收藏
回答

正式服务器请求微信登录api接口,响应时间很长,但测试服务器请求就很快,是我们服务器被限制请求速度?

public function wechatAppLogin($code)

    {

        log::write("进来微信登录了!!!!!!!!!!!!!");

        try {


            $url = 'https://api.weixin.qq.com/sns/oauth2/access_token';


            $params = [

                'appid'      => sysconf('wechat_app_appid'),

                'secret'     => sysconf('wechat_app_secret'),

                'code'       => $code,

                'grant_type' => 'authorization_code'

            ];


            $result = Http::get($url, $params);


            $info = WechatService::app()->login($result['access_token'], $result['openid']);

         

            log::write('微信登陆请求:'.json_encode($info));

        } catch (\Exception $exception) {

            log::write(11111111111111);

            $this->errorCode(999, $exception->getMessage());

        }

        $token = Token::encode($info);

       log::write('微信登陆请求:'.json_encode($info['wechat_login']));

        if ($info['wechat_login']) {

            //  判断是否存在token  有token的话就绑定这个微信号到这个用户信息上

            $token['is_phone'] = $info['phone'] ? 1 : 0;

            $token['is_has_baby'] = UserBaby::where('user_id', $info['id'])->unDel()->count() > 0 ? 1 : 0;

            $this->successCode($token);

        } else {

            $this->successCode(['wechat_app' => $token['token']], 2001, '微信绑定手机号');

        }

    }


回答关注问题邀请回答
收藏

1 个回答

  • YoKo
    YoKo
    03-06

    你们正式服务器跟测试服务器有啥区别地方 ,是不是正式限制比测试多

    03-06
    有用
    回复
登录 后发表内容