这个问题在这里已有答案:
客户端错误:POST https://graph.facebook.com/v3.0/oauth/access_token
导致了400 Bad Request
响应:{“错误”:{“消息”:“\ u05d0 \ u05d9 \ u05df \ u05d0 \ u05e4 \ u05e9 \ u05e8 \ u05d5 \ u05ea \ u05dc \ u05d8 \ u05e2 \ u05d5 \ u05df \ u05d0 \ u05ea(截断... )
在laravel中安装socialite包
public function Callback(Request $request, $provider)
{
try {
$userSocial = Socialite::driver($provider)->stateless()->user();
}
catch (Exception $e) {
return redirect ('/');
}
if (!$request->has('code') || $request->has('denied')) {
return redirect('/');
}
//$userSocial = Socialite::driver($provider)->stateless()->user();
$users = User::where(['email' => $userSocial->getEmail()])->first();
if($users){
Auth::login($users);
return redirect('/home');
}
else
{
$user = User::create([
'name' => $userSocial->getName(),
'email' => $userSocial->getEmail(),
'image' => $userSocial->getAvatar(),
'provider_id' => $userSocial->getId(),
'provider' => $provider,
]);
return redirect()->route('/home');
}
任何帮助都非常感谢。
你可以使用这个php sdk(https://github.com/facebook/php-graph-sdk)。它支持php 5.4版。