PHP code example of cresjie / social-login
1. Go to this page and download the library: Download cresjie/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/ */
cresjie / social-login example snippets
'providers' => array(
...
'Cresjie\SocialLogin\SocialLoginServiceProvider'
)
Route::get('/login/{provider}',function($provider){
return SocialLogin::login($provider);
});
Route::get('/login/{provider}/callback',function($provider){
var_dump( SocialLogin::authenticate($provider) );
});
Route::get('/login/{provider}/callback',function($provider){
$results = SocialLogin::authenticate($provider);
echo $results['picture']; // for goole
echo $results['avatar_url']; //for github
});
Route::get('/login/{provider}/callback',function($provider){
$results = SocialLogin::authenticate($provider);
echo $results['image']; //uniform call
});
$ php artisan config:publish cresjie/social-login
app/config/packages/cresjie/social-login/config.php
javascript
return [
'google' => [
...
'filter_result' => function($result){
$result['image'] = $result['picture'];
return $result; //should have return value
}
],
'github' => [
...
'filter_result' => function($result){
$result['image'] = $result['avatar_url'];
return $result;
}
]
];