From fdddb6261415591135fcf14bfc15363e63e9d0a8 Mon Sep 17 00:00:00 2001 From: Vernard Alexis Luz Date: Sat, 12 Nov 2016 17:30:28 +0800 Subject: [PATCH 1/2] Automatically set access token that is on the session --- .../LaravelFacebookSdkServiceProvider.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/LaravelFacebookSdk/LaravelFacebookSdkServiceProvider.php b/src/LaravelFacebookSdk/LaravelFacebookSdkServiceProvider.php index 729cb09..363e44d 100644 --- a/src/LaravelFacebookSdk/LaravelFacebookSdkServiceProvider.php +++ b/src/LaravelFacebookSdk/LaravelFacebookSdkServiceProvider.php @@ -55,6 +55,13 @@ public function register() return new LaravelFacebookSdk($app['config'], $app['url'], $config); }); + + $this->app->resolving('SammyK\LaravelFacebookSdk\LaravelFacebookSdk', function($obj, $app) { + /** @var \SammyK\LaravelFacebookSdk\LaravelFacebookSdk $obj */ + if ($accessToken = session()->get('fb_user_access_token')) { + $obj->setDefaultAccessToken($accessToken); + } + }); } private function isLumen() From 230684bc706f252ba052e75a17bd1ceced8f3d36 Mon Sep 17 00:00:00 2001 From: Vernard Alexis Luz Date: Sat, 12 Nov 2016 17:36:33 +0800 Subject: [PATCH 2/2] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 0af3a1b..711a37e 100755 --- a/README.md +++ b/README.md @@ -216,7 +216,7 @@ Route::get('/facebook/callback', function(SammyK\LaravelFacebookSdk\LaravelFaceb $fb->setDefaultAccessToken($token); - // Save for later + // Save in session so that the token is loaded on the next request. Do not change the session variable name. Session::put('fb_user_access_token', (string) $token); // Get basic info on the user from Facebook.