PHP code example of xuejd3 / socialiteproviders-xianyan_bbs

1. Go to this page and download the library: Download xuejd3/socialiteproviders-xianyan_bbs 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/ */

    

xuejd3 / socialiteproviders-xianyan_bbs example snippets


'providers' => [
    // a whole bunch of providers
    // remove 'Laravel\Socialite\SocialiteServiceProvider',
    \SocialiteProviders\Manager\ServiceProvider::class, // add
];

/**
 * The event handler mappings for the application.
 *
 * @var array
 */
protected $listen = [
    \SocialiteProviders\Manager\SocialiteWasCalled::class => [
        // add your listeners (aka providers) here
        'SocialiteProviders\XianYanBbs\XianYanBbsExtendSocialite@handle',
    ],
];

'xianyan_bbs' => [
    'client_id'     => env('XIANYANBBS_KEY'),
    'client_secret' => env('XIANYANBBS_SECRET'),
    'redirect'      => env('XIANYANBBS_REDIRECT_URI'),
    'guzzle'        => [
        'headers' => ['User-Agent' => 'xuejd3/socialiteproviders-xianyan_bbs'],
    ]
]

return Socialite::with('xianyan_bbs')->redirect();

$user = Socialite::driver('xianyan_bbs')->user();

$user->getId();
$user->getName();
$user->getEmail();
$user->getAvatar();

$clientId = "secret";
$clientSecret = "secret";
$redirectUrl = "http://yourdomain.com/api/redirect";
$additionalProviderConfig = [
    // Add additional configuration values here.
];
$config = new \SocialiteProviders\Manager\Config(
    $clientId,
    $clientSecret,
    $redirectUrl,
    $additionalProviderConfig
);

return Socialite::with('xianyan_bbs')->setConfig($config)->redirect();

$user = Socialite::driver('xianyan_bbs')->user();
$accessTokenResponseBody = $user->accessTokenResponseBody;