kuainiu/laravel-kuainiu
最新稳定版本:2.0.0
Composer 安装命令:
composer require kuainiu/laravel-kuainiu
包简介
API client wrapper for Laravel & Connect provider for Laravel Socialite
关键字:
README 文档
README
Laravel-Kuainiu incorporates Kuainiu Connect and the Kuainiu API into your Laravel
Requirements
- Laravel Socialite (if you intend on using Kuainiu Connect)
Installation
Add Laravel-Kuainiu to your composer file via the composer require command:
$ composer require kuainiu/laravel-kuainiu
Or add it to composer.json manually:
"require": { "kuainiu/laravel-kuainiu": "~1.0" }
Configuration
To get started, you'll need to publish all vendor assets:
$ php artisan vendor:publish --provider="Kuainiu\KuainiuServiceProvider"
This will create a config/kuainiu.php file in your app that you can modify to set your configuration.
Kuainiu PAssport Connect with Laravel Socialite
If you intend on using Kuainiu Connect, update config/services.php by adding this to the array:
'kuainiu' => [ 'oauthServerDomain' => env('KUAINIU_OAUTH_DOMAIN'), 'client_id' => env('KUAINIU_CLIENT_ID', 'app_xxx'), 'client_secret' => env('KUAINIU_CLIENT_SECRET'), 'redirect' => env('KUAINIU_REDIRECT_URI'), ],
To make sure Laravel Socialite can actually find the Kuainiu driver, use the following code snippet and paste it in the boot() method from your AppServiceProvider.php.
Socialite::extend('kuainiu', function ($app) { $config = $app['config']['services.kuainiu']; return Socialite::buildProvider('Kuainiu\KuainiuConnectProvider', $config); });
Usage
Here you can see an example of just how simple this package is to use.
Kuainiu API
$user = Kuainiu::api()->user()->create([ "name" => 'user_name_', "mobile" => "13800138000" ]); $user = Kuainiu::createUser(['name'=>'name']); if ($user->isCreated()) { echo "User Created."; }
Kuainiu Passport Connect with Laravel Socialite
Route::get('login', function () { return Socialite::with('kuainiu') ->scopes('profiles.read profiles.write') // Additional permission: profiles.read profiles.write(the string need space separator) ->redirect(); }); Route::get('kuainiu/user/auth', function () { $user = Socialite::with('kuainiu')->stateless()->user(); dd($user); });
License
Copyright (c) 2018, Kuainiu Group
统计信息
- 总下载量: 12.85k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: BSD-2-Clause
- 更新时间: 2018-05-11