PHP code example of mehdibo / ft-client

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

    

mehdibo / ft-client example snippets




$client = \Mehdibo\FortyTwo\Client\BasicClientFactory::createFromCredentials(
    'CLIENT_ID',
    'CLIENT_SECRET',
    'REDIRECT_URI'
);

$client->fetchTokenFromAuthCode($_GET['code']);
$user = $client->get("/me");



$client = \Mehdibo\FortyTwo\Client\BasicClientFactory::createFromCredentials(
    'CLIENT_ID',
    'CLIENT_SECRET',
    'REDIRECT_URI'
);

// This is not necessary, if no token was fetched it will automatically fetch one using the Client Credentials grant
$client->fetchTokenFromClientCredentials();

$cute = $client->get("/users/norminet");



$client = \Mehdibo\FortyTwo\Client\BasicClientFactory::createFromCredentials(
    'CLIENT_ID',
    'CLIENT_SECRET',
    'REDIRECT_URI'
);

$users = $client->enumerate("/users", [
    'sort' => '-id',
]);

try {
    foreach ($users as $user) {
        echo $user['login'] . PHP_EOL;
    }
} catch (\Mehdibo\FortyTwo\Client\Exception\EnumerationRateLimited $e) {
    echo "Rate limited, retry in " . $e->retryAfter . " seconds\n";
    echo "Stopped at page " . $e->reachedPage . "\n";
}