Package Data | |
---|---|
Maintainer Username: | tiup |
Package Create Date: | 2017-05-26 |
Package Last Update: | 2017-07-19 |
Language: | PHP |
License: | TiUP |
Last Refreshed: | 2024-11-22 03:11:10 |
Package Statistics | |
---|---|
Total Downloads: | 67 |
Monthly Downloads: | 0 |
Daily Downloads: | 0 |
Total Stars: | 0 |
Total Watchers: | 2 |
Total Forks: | 1 |
Total Open Issues: | 0 |
composer require tiup/tiupsdk-laravel
修改 config/app.php
在providers中增加
Tiup\LaravelTiupSdk\LaravelTiupSdkServiceProvider::class,
在 aliases 中增加
'Tiup' => Tiup\LaravelTiupSdk\TiupFacade::class,
php artisan vendor:publish --provider="Tiup\LaravelTiupSdk\LaravelTiupSdkServiceProvider"
TIUP_CLIENT_ID=client_id
TIUP_CLIENT_SECRET=client_secret
TIUP_AUTH_HOST=https://test.tiup.cn/
TIUP_API_HOST=https://test.tiup.cn/
运行 php artisan serve
启动即可
应用首页 http://127.0.0.1:8000
登录回调 http://127.0.0.1:8000/oauth/callback
代码示例
Route::get('/', function () {
//获取登录地址
$url = Tiup::getAuthorizationUrl('http://127.0.0.1:8000/oauth/callback');
return redirect($url);
});
Route::get('/oauth/callback', function () {
//登录成功回调,获取用户信息
$token = \Tiup::getAccessToken();
$userinfo = \Tiup::me($token);
dd($userinfo);
});