PHP code example of kuainiu / laravel-kuainiu
1. Go to this page and download the library: Download kuainiu/laravel-kuainiu library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
kuainiu / laravel-kuainiu example snippets
'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'),
],
Socialite::extend('kuainiu', function ($app) {
$config = $app['config']['services.kuainiu'];
return Socialite::buildProvider('Kuainiu\KuainiuConnectProvider', $config);
});
$user = Kuainiu::api()->user()->create([
"name" => 'user_name_',
"mobile" => "13800138000"
]);
$user = Kuainiu::createUser(['name'=>'name']);
if ($user->isCreated())
{
echo "User Created.";
}
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);
});
bash
$ php artisan vendor:publish --provider="Kuainiu\KuainiuServiceProvider"