<?php
/*
* This file is part of the Showpad PHP API connection class from Jeroen Desloovere.
*
* For the full copyright and license information, please view the license
* file that was distributed with this source code.
*/
// required to load
require_once __DIR__ . '/../vendor/autoload.php';
require_once __DIR__ . '/credentials.php';
// See class comments and Asana API for full info
$asana = new Asana(array('apiKey' => 'xxxxxxxxxxxxxxxxxxxxx'));
// Your API Key, you can get it in Asana
// Get all workspaces
$workspaces = $asana->getWorkspaces();
// As Asana API documentation says, when response is successful, we receive a 200 in response so...
if ($asana->responseCode != '200' || is_null($workspaces)) {
echo 'Error while trying to connect to Asana, response code: ' . $asana->responseCode;
return;
}
$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;
}