}
$workspacesJson = json_decode($workspaces);
foreach ($workspacesJson->data as $workspace) {
echo '<h3>*** ' . $workspace->name . ' (id ' . $workspace->id . ')' . ' ***</h3><br />' . PHP_EOL;
// Get all projects in the current workspace (all non-archived projects)
$projects = $asana->getProjectsInWorkspace($workspace->id, $archived = false);
// As Asana API documentation says, when response is successful, we receive a 200 in response so...
if ($asana->responseCode != '200' || is_null($projects)) {
echo 'Error while trying to connect to Asana, response code: ' . $asana->responseCode;
continue;
}
$projectsJson = json_decode($projects);
foreach ($projectsJson->data as $project) {
// Get all tasks in the current project
$tasks = $asana->getTasksByFilter(['project' => $project->id, 'workspace' => $workspace->id],
['modified_since' => $startTasksDate/*, 'opt_fields' => 'tags, name'*/]);
// var_dump($tasks);die;
$tasksJson = json_decode($tasks);
if ($asana->responseCode != '200' || is_null($tasks)) {
echo 'Error while trying to connect to Asana, response code: ' . $asana->responseCode;
continue;
}
$tasks = array();
foreach ($tasksJson->data as $task) {
$lastChar = substr(trim($task->name), -1);
if ($lastChar != ':') {
$tasks[] = '+ <a target="_blank" href="https://app.asana.com/0/' . $project->id . '/' . $task->id . '">' . $task->name . '</a> '
/*.(($task->tags) ? " [".implode (", ", $task->tags)."] " : '')*/ . '<br>' . PHP_EOL;
}
}