PHP code example of welderlourenco / laravel-facebook
1. Go to this page and download the library: Download welderlourenco/laravel-facebook library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
welderlourenco / laravel-facebook example snippets
return array(
// ...
'providers' => array(
// At the end of this array, push Laravel Facebook provider:
'WelderLourenco\Facebook\Providers\FacebookServiceProvider'
),
'aliases' => array(
// At the end of this array, push Laravel Facebook facade:
'Facebook' => 'WelderLourenco\Facebook\Facades\Facebook'
)
)
return array(
/*
|--------------------------------------------------------------------------
| facebook-php-sdk-v4
|--------------------------------------------------------------------------
|
| Essential data provided for the facebook-php-sdk-v4. The app-id and
| app-secret won't even be touched by welderlourenco/laravel-facebook's
| package.
|
*/
'appId' => '', // Id of your facebook app.
'appSecret' => '', // Secret of your facebook app.
'redirectUrl' => '' // Where to process the facebook answer.
);
echo Facebook::connect()->getLoginUrl(array('email'));
// public_profile (default scope) and email
$accessToken = Facebook::process()->getLongLivedSession()->getToken();
// Now that you have the access token, do whatever you want with it, store in database or in a cookie, it is you call.
// FacebookSession, you'll need this to make any api calls.
$session = Facebook::process()->getLongLivedSession();
// Access Token
$accessToken = $session->getToken();
// User info
$user = Facebook::api($session, 'GET', '/me');