LaravelPackages.net
Acme Inc.
Toggle sidebar
tayokin/laravel-facebook-accountkit

Laravel Facebook Account Kit SDK (PHP)

1.178
2
v1.0.3
About tayokin/laravel-facebook-accountkit

tayokin/laravel-facebook-accountkit is a Laravel package for laravel facebook account kit sdk (php). It currently has 2 GitHub stars and 1.178 downloads on Packagist (latest version v1.0.3). Install it with composer require tayokin/laravel-facebook-accountkit. Discover more Laravel packages by tayokin or browse all Laravel packages to compare alternatives.

Last updated

Laravel Facebook Account Kit

License

A simple package to make Password-less Login possible in Laravel using Facebook's Account Kit.

Requirements

php 7.1+

Composer

Laravel 5.x

Installation

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

Usage

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" => ""
]

Views

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">

Testing

$ vendor/bin/phpunit test

Credits

This package is maintained by Tayokin Max.

Change log

Please check out CHANGELOG file for information on what has changed recently.

License

This package is released under the MIT Licence. See the bundled LICENSE file for details.

Comments