客户端错误:`POST https:// graph.facebook.com / v3.0 / oauth / access_token`导致`400错误请求`

时间:2019-04-17 05:43:43

标签: laravel facebook-graph-api

客户端错误: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中安装社交名流包

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');
    }

我们非常感谢您的帮助。

1 个答案:

答案 0 :(得分:0)

您可以使用此php sdk(https://github.com/facebook/php-graph-sdk)。从5.4版开始支持。