| xqd
@@ -88,6 +88,14 @@ class AuthController extends Controller
|
|
|
return $this->validatorError($validator->messages()->all(),ErrorCode::CLIENT_WRONG_PARAMS);
|
|
|
$phone = $request->phone;
|
|
|
$wechat = $request->wechat;
|
|
|
+
|
|
|
+ $url = "https://api.weixin.qq.com/sns/oauth2/access_token?appid=wxd2334195ddfc7d93&secret=c349515d0079ccbc71f4a4f191c1621e&code=".$wechat."&grant_type=authorization_code";
|
|
|
+ $res = file_get_contents($url); //file_get_contents获取指定路由返回的数据
|
|
|
+ \Log::info($res);
|
|
|
+ $arr = json_decode($res, true);
|
|
|
+ $openid = $arr['openid'];
|
|
|
+ \Log::info('openid: ' . $openid);
|
|
|
+
|
|
|
$jpush = $request->jpush;
|
|
|
$key = $this->keySmsCode . $phone;
|
|
|
$code = Cache::store('file')->get($key);
|
| xqd
@@ -97,7 +105,7 @@ class AuthController extends Controller
|
|
|
if (empty($user)) {
|
|
|
$user = UserInfoModel::create([
|
|
|
'phone'=>$phone,
|
|
|
- 'wechat'=>$wechat,
|
|
|
+ 'wechat'=>$openid,
|
|
|
'jpush'=>$jpush,
|
|
|
'password'=>bcrypt(123456)
|
|
|
]);
|
| xqd
@@ -170,7 +178,15 @@ class AuthController extends Controller
|
|
|
|
|
|
if ($validator->fails())
|
|
|
return $this->validatorError($validator->messages()->all(),ErrorCode::CLIENT_WRONG_PARAMS);
|
|
|
- $user = UserInfoModel::where('wechat',$request->wechat)->first();
|
|
|
+
|
|
|
+
|
|
|
+ $url = "https://api.weixin.qq.com/sns/oauth2/access_token?appid=wxd2334195ddfc7d93&secret=c349515d0079ccbc71f4a4f191c1621e&code=".$request->wechat."&grant_type=authorization_code";
|
|
|
+ $res = file_get_contents($url); //file_get_contents获取指定路由返回的数据
|
|
|
+ \Log::info($res);
|
|
|
+ $arr = json_decode($res, true);
|
|
|
+ $openid = $arr['openid'];
|
|
|
+ \Log::info('openid: ' . $openid);
|
|
|
+ $user = UserInfoModel::where('wechat',$openid)->first();
|
|
|
if (empty($user)) {
|
|
|
// return $this->error(ErrorCode::LOGIN_FAILED);
|
|
|
}else{
|