error while try to iterate Asana\Iterator\ItemIterator object

There is not much information with regards to this post so not 100% sure what you trying to achieve.

getTask() returns information for an individual task, here is an example to access that specific data for the required task.

<?php
require 'vendor/autoload.php';

$client = Asana\Client::accessToken('INSERT ACCESS TOKEN HERE', 
    array('headers' => array('asana-enable' => 'new_user_task_lists')));  // Asana Deprecation

$task_gid = 'XXXXXXXXXXXXXXXX'; insert task id

$tasks = $client->tasks->getTask($task_gid);

// Examples
echo $tasks->name . '<br>';
echo $tasks->notes . '<br>';
echo $tasks->assignee->name . '<br>';
echo $tasks->assignee->gid . '<br>';
echo $tasks->workspace->gid . '<br>';

I do see you are using getTasks() so it seems you trying to get information for all tasks under a project. Here is what I did to get all tasks under a project.

<?php
require 'vendor/autoload.php';

$client = Asana\Client::accessToken(''INSERT ACCESS TOKEN HERE');

$project_id = 'XXXXXXXXXXXXXXX'; // Insert project Id you want to pull tasks from

$tasks = $client->tasks->getTasksForProject($project_id);

foreach($tasks as $task) {
	echo $task->name . ": " .  $task->gid . "<br>";
}
1 Like