PHP code example of changyy / laravel-oauth-library
1. Go to this page and download the library: Download changyy/laravel-oauth-library 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/ */
changyy / laravel-oauth-library example snippets
$ php composer.phar controller OAuthConnect
$ vim app/Http/Controllers/OAuthConnect.php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
class OAuthConnect extends \org\changyy\OAuth\Controller\Connect
{
public function handleFacebookConnected($oauth_ret = []) {
print_r($oauth_ret);
}
public function initFacebook() {
if(!session_id())
session_start();
parent::initFacebook();
}
public function handleGoogleConnected($oauth_ret = []) {
print_r($oauth_ret);
}
}
$ vim routes/web.php
Route::get('/connect/facebook', 'OAuthConnect@connectFacebook');
Route::get('/connect/google', 'OAuthConnect@connectGoogle');
$ vim config/oauth.php
return [
'methods' => [
'facebook' => [
'tag' => 'facebook',
'default_graph_version' => 'v2.9',
'app_id' => 'xxxxx',
'secret_key' => 'xxxxxx',
'scope' => [ 'email' ],
'done_handler' => '/',
'error_handler' => '/connect/error',
],
'google' => [
'tag' => 'google',
'client_id' => 'xxxxx',
'client_secret' => 'xxxxx',
'scope' => [ 'email', 'profile' ],
'done_handler' => '/',
'error_handler' => '/connect/error',
],
];
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.