tayokin/laravel-facebook-accountkit
Composer 安装命令:
composer require tayokin/laravel-facebook-accountkit
包简介
Laravel Facebook Account Kit SDK (PHP)
README 文档
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.
统计信息
- 总下载量: 1.18k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 2
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2018-04-08