tayokin / laravel-facebook-accountkit
Laravel Facebook Account Kit SDK (PHP)
Installs: 1 159
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 1
Forks: 0
Open Issues: 0
Requires
- php: >=7.1.0
- guzzlehttp/guzzle: ^6.2
- illuminate/support: >=5.1
Requires (Dev)
- phpunit/phpunit: >=5.4.3
- squizlabs/php_codesniffer: ^2.3
This package is not auto-updated.
Last update: 2024-05-06 14:35:28 UTC
README
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.