PHP code example of farzak / socialite

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

    

farzak / socialite example snippets


$config = [
    'client_id' => 'xxx',
    'client_secret' => 'xxx',
    'redirect' => 'http://example.com/callback.php',
];

use Socialite\Socialite;

Socialite::driver('twitter', $config)->redirect();

use Socialite\Socialite;

$user = Socialite::driver('twitter', $config)->user();

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

Socialite::driver('twitter', $config)
    ->setRequest($this->request);

Socialite::driver('twitter', $config)
    ->setSession($this->request->getSession());

PHP >= 7.0