PHP code example of droidwiki / xenforo-bd-client

1. Go to this page and download the library: Download droidwiki/xenforo-bd-client 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/ */

    

droidwiki / xenforo-bd-client example snippets


$client = new \XenForoBDClient\Clients\OAuth2Client();
$client->setBaseUrl( 'https://example.com/api/' )
	->setClientId( 'client_id' )
	->setClientSecret( 'client_secret' )
	->setRedirectUri( 'https://example2.com/redirect_target.php' )
	// see \XenForoBD\Scopes for all possible scopes
	->addScope( \XenForoBD\Scopes::READ );
if ( $_GET[ 'code' ] ) {
	$client->authenticate( $_GET['code'] );
	$user = new \XenForoBDClient\Users\User( $client );
	// will print the whole information array of the authenticated user
	var_dump($user->get( 'me' ));
} else {
	// redirect to the authentication url
	header( 'Location: ' . $client->getAuthenticationRequestUrl() );
}

$client = new \XenForoBDClient\Clients\UnauthenticatedClient();
$client->setBaseUrl( 'http://www.android-hilfe.de/api/' );
$user = new \XenForoBDClient\Users\User( $client );
// the user id in XenForo would be 102719
var_dump( $user->get( 102719 ) );