getProjectTasks() public method

Returns all unarchived tasks of a given project
public getProjectTasks ( string $projectId, array $opts = [] ) : string
$projectId string
$opts array Array of options to pass (@see https://asana.com/developers/documentation/getting-started/input-output-options)
return string JSON or null
    echo "{$proj}";
    if ($proj == "projectid_1") {
        $projselect = XXXXXXXXXXXXX;
    }
    if ($proj == "projectid_2") {
        $projselect = XXXXXXXXXXXXX;
    }
    if ($proj == "projectid_3") {
        $projselect = XXXXXXXXXXXXX;
    }
    if ($proj == "projectid_4") {
        $projselect = XXXXXXXXXXXXX;
    }
    if ($proj == "projectid_5") {
        $projselect = XXXXXXXXXXXXX;
    }
    echo "{$projselect}";
}
// See class comments and Asana API for full info
$asana = new Asana(array('apiKey' => 'XXXXXXXXXXXXXXXXXXXXXXXXXX'));
// Your API Key, you can get it in Asana
$projectId = $projselect;
// Your Project ID Key, you can get it in Asana
$result = $asana->getProjectTasks($projectId);
// As Asana API documentation says, when response is successful, we receive a 200 in response so...
if ($asana->responseCode != '200' || is_null($result)) {
    echo 'Error while trying to connect to Asana, response code: ' . $asana->responseCode;
    return;
}
$resultJson = json_decode($result, true);
//var_dump($resultJson);
示例#2
0
<?php

ini_set("max_execution_time", 300);
require_once 'asana.php';
$asana = new Asana(array('apiKey' => 'bZN6mBeL.7cBWsHfKEMSPcNP4gmRHiIq'));
$tasks = $asana->getProjectTasks(42248342439432);
$tasksJson = json_decode($tasks);
?>

<!DOCTYPE html>
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]> <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>ASANA</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="assets/bootstrap.css">
<style>
  body {
  padding-top: 10px;
  padding-bottom: 10px;
  }
</style>

<link rel="stylesheet" href="assets/style.css">
<script src="assets/bootstrap.js"></script>
<script src="assets/jquery.js"></script>
$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;
    }
    $projectsJson = json_decode($projects);
    foreach ($projectsJson->data as $project) {
        echo '<strong>[ ' . $project->name . ' (id ' . $project->id . ')' . ' ]</strong><br>' . PHP_EOL;
        // Get all tasks in the current project
        $tasks = $asana->getProjectTasks($project->id);
        $tasksJson = json_decode($tasks);
        if ($asana->responseCode != '200' || is_null($tasks)) {
            echo 'Error while trying to connect to Asana, response code: ' . $asana->responseCode;
            continue;
        }
        foreach ($tasksJson->data as $task) {
            echo '+ ' . $task->name . ' (id ' . $task->id . ')' . ' ]<br>' . PHP_EOL;
        }
    }
}
<?php

require_once '../asana.php';
// See class comments and Asana API for full info
$asana = new Asana(array('personalAccessToken' => 'xxxxxxxxxxxxxxxxxxxxx'));
// Create a personal access token in Asana or use OAuth
$projectId = 'XXXXXXXXXXXXXXXXXXX';
// Your Project ID Key, you can get it in Asana
$asana->getProjectTasks($projectId);
// As Asana API documentation says, when response is successful, we receive a 200 in response so...
if ($asana->hasError()) {
    echo 'Error while trying to connect to Asana, response code: ' . $asana->responseCode;
    return;
}
echo '<pre>';
var_dump($asana->getData());
echo '</pre>';