PHP code example of phantom / oauth2-social-login

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

    

phantom / oauth2-social-login example snippets


'providers' => array(
	// ...
	'Phantom\Oauth2SocialLogin\Oauth2SocialLoginServiceProvider',
)

<a href="{{ {{Facebook::getLoginUrl()}} }}">
	Connect Your Facebook Account
</a>

$code = Input::get('code');
$token = Facebook::getToken($code);

$user = Facebook::getUserInfo($token);

	try{}catch(Exception $exp){
		switch($exp->getCode()){
			case 401: //The provider did not provide you and access token
				break;
			case 415: //The response with user info have bad formatted data
				break;
			default: //There was a problem connecting to provider
		}
	}
console
$ php artisan config:publish phantom/oauth2-social-login