Asana::getTask PHP Method

getTask() public method

Returns task information
public getTask ( string $taskId, array $opts = [] ) : string
$taskId string
$opts array Array of options to pass (@see https://asana.com/developers/documentation/getting-started/input-output-options)
return string JSON or null
    public function getTask($taskId, array $opts = array())
    {
        $options = http_build_query($opts);
        return $this->askAsana($this->taskUrl . '/' . $taskId . '?' . $options);
    }

Usage Example

<?php

require_once '../asana.php';
// See class comments and Asana API for full info
$asana = new Asana(array('apiKey' => 'XXXXXXX.XXXXXXXXXXXXXXXXXXXXXXXX'));
// Your API Key, you can get it in Asana
$taskId = 10924433056204.0;
$resultJson = $asana->getTask($taskId);
// As Asana API documentation says, when response is successful, we receive a 200 in response so...
if ($asana->responseCode != '200' || is_null($resultJson)) {
    echo 'Error while trying to connect to Asana, response code: ' . $asana->responseCode;
    return;
}
$task = json_decode($resultJson);
echo "Task details:" . PHP_EOL;
var_dump($task);
$resultJson = $asana->getTaskStories($taskId);
// As Asana API documentation says, when response is successful, we receive a 200 in response so...
if ($asana->responseCode != '200' || is_null($resultJson)) {
    echo 'Error while trying to connect to Asana, response code: ' . $asana->responseCode;
    return;
}
$stories = json_decode($resultJson);
echo "Task stories(comments):" . PHP_EOL;
var_dump($stories);
All Usage Examples Of Asana::getTask