app_id . '&secret=' . $we_chat->app_secret . '&js_code=' . $code . '&grant_type=authorization_code'; $info = file_get_contents($url); $json = json_decode($info); return get_object_vars($json); } public function login($code, $app_id) { $we_chat = WeChat::where('app_id', $app_id)->first(); $login = false; if (!$we_chat) return false; switch ($we_chat->type) { case 1: break; case 2: $login = $this->mp_login($we_chat, $code); break; } return $login; } public function login_test(Request $request) { $code = $request->post('code'); $app_id = $request->post('app_id'); return Yo::echo([ 'info' => $this->login($code, $app_id) ]); } }