PHP code example of sas1024 / socialite-xenforo-bdapi

1. Go to this page and download the library: Download sas1024/socialite-xenforo-bdapi 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/ */

    

sas1024 / socialite-xenforo-bdapi example snippets


    /**
     * The event listener mappings for the application.
     *
     * @var array
     */
    protected $listen = [
        'App\Events\Event' => [
            'App\Listeners\EventListener',
        ],
        SocialiteWasCalled::class => [
            'Sas1024\Socialite\XenForo\XenForoExtendSocialite@handle',
        ],
    ];

    'xenforo' => [
        'client_id' => env('XENFORO_CLIENT_ID'),
        'client_secret' => env('XENFORO_CLIENT_SECRET'),
        'redirect' => env('XENFORO_CALLBACK_URL'),
        'xenforo_url' => env('XENFORO_URL'),
    ],



namespace App\Http\Controllers\Auth;

use Socialite;

class AuthController extends Controller
{
    /**
     * Redirect the user to the XenForo [bd] Api authentication page.
     *
     * @return Response
     */
    public function redirectToProvider()
    {
        return Socialite::driver('xenforo')->redirect();
    }

    /**
     * Obtain the user information from XenForo [bd] Api.
     *
     * @return Response
     */
    public function handleProviderCallback()
    {
        $user = Socialite::driver('xenforo')->user();
    }
}

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

$token = $user->token;
$expiresIn = $user->expiresIn;
$user->id;
$user->avatar;
$user->nickname;
$user->email;