PHP code example of buerxiaojie / laravel-oauth

1. Go to this page and download the library: Download buerxiaojie/laravel-oauth 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/ */

    

buerxiaojie / laravel-oauth example snippets


composer 

  Buerxiaojie\Providers\OauthServiceProvider::class,

  'OauthUser' => Buerxiaojie\Facades\Oauth::class,

	use Buerxiaojie\Oauth;

	Oauth::routes();

  php artisan vendor:publish

  /**
   * 加入以下
   * 
   */
   
  	'qq' => [
		'app_id' => 'YOUR APP ID',
		'app_secret' => 'YOUR APP SECRET',
	],
	'wechat' => [
		'app_id' => 'YOUR APP ID',
		'app_secret' => 'YOUR APP SECRET'
	]
 

	/**
	*业务处理
	*/
	public function handle()
	{
		//$oauthUser 即为获取的用户信息
		$oauthUser = OauthUser::userInfo();

		/**
		*业务处理
		*/
	}


	php artisan make:oauthServer Github

  /**
   * 加入以下
   * 
   */
   'servers' => [
		'github' => 'App\Oauth\Servers\Github',
	],
   

  'github' => [
		'app_id' => 'YOUR APP ID',
		'app_secret' => 'YOUR APP SECRET',
	]
 

	<a href="/oauth/oauth-login?server=github"><img src=""></a>

	use OauthUser;

	public function oauthCallback(Request $request)
	{
		$userInfo = OauthUser::getUserInfo($request);

		/**
		* 其他业务逻辑
		*/
	}