PHP code example of aiddroid / social

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

    

aiddroid / social example snippets




//client config
$config = [
    'weibo' => [
        'client_id' => '384556****',
        'client_secret' => '507a34706a4cfffb87f7f06*****',
        'redirect_url' => 'http://localhost.dev/callback.php',
        'addition' => [
            'scopes' => ['email']
        ]
    ],
    'qq' => [
        'client_id' => '10115****',
        'client_secret' => '2ee893df483e0a5a521d768683******',
        'redirect_url' => 'http://localhost.dev/callback.php',
    ],
    'wechat' => [
        'client_id' => 'wx8b160f63e30*****',
        'client_secret' => 'f88eede680e8e6e7a7ea4b8******',
        'redirect_url' => 'http://localhost.dev/callback.php',
    ],
    'github' => [
        'client_id' => '41473a449fb5d6******',
        'client_secret' => '5fea02f02998356b039b75f6d861f*******',
        'redirect_url' => 'http://localhost.dev/callback.php'
    ],
    'facebook' => [
        'client_id' => '99544295*****',
        'client_secret' => '5ccff1d484c5ae417f7d1aa*******',
        'redirect_url' => 'http://localhost.dev/callback.php'
    ],
    'google' => [
        'client_id' => '8983768*****-qf*******.apps.googleusercontent.com',
        'client_secret' => 'M5XhtghGBZC_Vwv*******',
        'redirect_url' => 'http://localhost.dev/callback.php'
    ]
];



//github demo
$social = new Social($config);
$provider = $social->driver('github');
return $provider->redirect('http://localhost/callback.php');


//github demo
$social = new Social($config);
$provider = $social->driver('github');
if(isset($_GET['code'])){
    $user = $provider->getUser();
}

    
    
    $social = new Social($config);
    $social->setDriverProvider('dummysocial', Aiddroid\Social\Providers\DummysocialProvider::class);
    $provider = $social->driver('dummysocial');
    
    $provider->redirect('http://localhost.dev/callback.php')