PHP code example of hfw / asana

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

    

hfw / asana example snippets


use Helix\Asana\Api;

$api = new Api( ACCESS TOKEN );

$me = $api->getMe();
echo $me->getUrl();

// if you're only in one workspace, then it's a safe default
$workspace = $api->getWorkspace();

// or you can set a default
$api->setWorkspace( GID );
$workspace = $api->getWorkspace();

// or you can get a specific workspace any time
$workspace = $api->getWorkspace( GID );

// create a project
$project = $workspace->newProject()
                     ->setName('Test Project')
                     ->setNotes('A test project.')
                     ->setOwner($me)
                     ->create();
echo $project->getUrl();

// get a project
$project = $api->getProject( GID );

// create a task
$task = $project->newTask()
                ->setAssignee($me)
                ->setName('Test Task')
                ->setNotes('A test task.')
                ->create();
echo $task->getUrl();

// iterate your tasks
$taskList = $me->getTaskList();
foreach ($taskList as $task){
    // ...
}