Downloads
Stars
Version
A simple package to make Password-less Login possible in Laravel using Facebook's Account Kit.
php 7.1+
Composer
Laravel 5.x
To use this package in a Laravel Project, install via Composer
$ composer require tayokin/laravel-facebook-accountkit
Register the package to the Service Provider in the config/app.php
file:
'providers' => [
...
Tayokin\FacebookAccountKit\FacebookAccountKitServiceProvider::class,
],
'aliases' => [
...
'AccountKit' => Tayokin\FacebookAccountKit\Facades\FacebookAccountKitFacade::class,
],
You can make of some assets provided in this package to speed up your implementation: run
$ php artisan vendor:publish
Create your app on Facebook following guidelines here.
You can view example here.
Update .env
file with credentials from Facebook:
ACCOUNTKIT_APP_ID=XXXXXXXXXXXX
ACCOUNTKIT_APP_SECRET=XXXXXXXXXXXXXXXXXXXXXXXX
ACCOUNTKIT_REDIRECT_URL=<path/to/endpoint>
Define your route in routes/web.php
. E.g:
Route::get('/<path/to/endpoint>', 'FacebookAccountKitController@endpoint');
Import the package in your Controller and use it therein. E.g:
use Tayokin\FacebookAccountKit\Facades\FacebookAccountKitFacade;
use Illuminate\Http\Request;
class FacebookAccountKitController extends Controller
{
...
public function endpoint(Request $request)
{
$accountData = FacebookAccountKitFacade::getAccountDataByCode($request->get('code'));
...
}
}
The above return an array similar to this:
[▼
"id" => "1802782826673865"
"phoneNumber" => "+38093XXXXXXX",
"email" => ""
]
Ensure your form has csrf_token
, E.g:
<input type="hidden" name="state" value="{{ csrf_token() }}" />
You can also specify country
. E.g:
<input type="hidden" name="country_code" value="UA">
$ vendor/bin/phpunit test
This package is maintained by Tayokin Max.
Please check out CHANGELOG file for information on what has changed recently.
This package is released under the MIT Licence. See the bundled LICENSE file for details.