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, '微信绑定手机号');
}
}
你们正式服务器跟测试服务器有啥区别地方 ,是不是正式限制比测试多