Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore.

15 St Margarets, NY 10033
(+381) 11 123 4567



Laravel Facebook Graph API | Laravel News

Laravel Facebook Graph by Joel Butcher is a Laravel integration for the Graph PHP 8 SDK project. This package makes it easy to integrate the PHP SDK (provided by the same author) and Facebook login into your Laravel projects.

After you install this package and configure your app, you can use the provided Facebook facade/service to access the Facebook API:

1// Facade

2Facebook::getUser(array $params);


4// Service container making a GET request

5app(JoelButcherFacebookFacebook::class)->get('/me', array $params);

Here’s an example from the underlying PHP 8 SDK to get a user name and ID:

1$fb = new FacebookFacebook([

2 'app_id' => '{app-id}',

3 'app_secret' => '{app-secret}',

4 'default_graph_version' => 'v2.10',

5 ]);


7try {

8 // Returns a `FacebookResponse` object

9 $response = $fb->get('/me?fields=id,name', '{access-token}');

10} catch(FacebookExceptionResponseException $e) {

11 echo 'Graph returned an error: ' . $e->getMessage();

12 exit;

13} catch(FacebookExceptionSDKException $e) {

14 echo 'Facebook SDK returned an error: ' . $e->getMessage();

15 exit;



18$user = $response->getGraphUser();


20// Array access

21echo 'Name: ' . $user['name'];

22// or get

23echo 'Name: ' . $user->getName();

Learn More

You can get started with this package by reading the documentation for the Graph PHP 8 SDK used by the Laravel wrapper. It includes plenty of examples.

To use this project in a Laravel app, check out joelbutcher/laravel-facebook-graph. Also, check out the PHP SDK used by the Laravel package.

Credit: Source link

Previous Next
Test Caption
Test Description goes like this