Search code examples
apilaravel-5laravel-socialite

How to get Facebook id using socialite laravel-5 using Face Book token


I am new in Laravel 5 I am creating API for Android app using Laravel 5 the other developer sent Facebook token in post method so I have the Facebook token I need guidelines to using the token to get Facebook id any help will be appreciated (i don't using socialite) Anyway thanks in advance, guys.


Solution

  • I solved it any way

      $client = new \GuzzleHttp\Client();
    
            try {
                $res = $client->get('https://graph.facebook.com/me?fields=name,picture&access_token=' . $facebook_token);
    
            } catch (RequestException $e) {
    
                $status = 'Login Invalid';
                return \Response::json(['status' => $status, 'user' => '']);
            }
            $facebookUser = json_decode($res->getBody());
    
            $facebookId = $facebookUser->id;
            $facebookUsername = $facebookUser->name;
            $facebookUserPicture = $facebookUser->picture;
            $pictureURL = $facebookUserPicture->data->url;
    

    hope that help any one