PHP code example of ikkez / f3-opauth

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

    

ikkez / f3-opauth example snippets


// adjust the autoloader
$f3->set('AUTOLOAD','lib/opauth/');

// in your index.php
$f3 = \Base::instance();
// load opauth config (allow token resolve)
$f3->config('lib/opauth/opauth.ini', TRUE);

// init with config
$opauth = OpauthBridge::instance($f3->opauth);

// define login handler
$opauth->onSuccess(function($data){
	header('Content-Type: text');
	echo 'User successfully authenticated.'."\n";
	print_r($data['info']);
});

// define error handler
$opauth->onAbort(function($data){
	header('Content-Type: text');
	echo 'Auth request was canceled.'."\n";
	print_r($data);
});

$f3->run();

$opauth->onSuccess('\Controller\User->socialLogin');