PHP code example of testmonitor / asana-client

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

    

testmonitor / asana-client example snippets




$oauth = [
    'clientId' => '12345',
    'clientSecret' => 'abcdef',
    'redirectUrl' => 'https://redirect.myapp.com/',
];

$asana = new \TestMonitor\Asana\Client($oauth);

header('Location: ' . $asana->authorizationUrl('state'));
exit();

$oauth = [
    'clientId' => '12345',
    'clientSecret' => 'abcdef',
    'redirectUrl' => 'https://redirect.myapp.com/',
];

$asana = new \TestMonitor\Asana\Client($oauth);

$token = $asana->fetchToken($_REQUEST['code']);

$oauth = ['clientId' => '12345', 'clientSecret' => 'abcdef', 'redirectUrl' => 'https://redirect.myapp.com/'];
$token = new \TestMonitor\Asana\Token('eyJ0...', '0/34ccc...', 1574600877); // the token you got last time

$asana = new \TestMonitor\Asana\Client($oauth, $token);

if ($token->expired()) {
    $newToken = $asana->refreshToken();
}

$workspaces = $asana->workspaces();

$task = $asana->createTask(new \TestMonitor\Asana\Resources\Task([
    'completed' => false,
    'name' => 'Name of the task',
    'notes' => 'Some notes',
]), '12345');