Asana::getData PHP Method

getData() public method

Decodes the response and returns as an object, array.
public getData ( ) : object,
return object,
    public function getData()
    {
        if (!$this->hasError()) {
            $array = $this->returnType == ASANA_RETURN_TYPE_ARRAY;
            $return = json_decode($this->response, $array);
            if ($array && isset($return['data'])) {
                return $return['data'];
            } elseif ($this->returnType == ASANA_RETURN_TYPE_OBJECT && isset($return->data)) {
                return $return->data;
            } elseif ($this->returnType == ASANA_RETURN_TYPE_JSON) {
                return $this->response;
            }
        }
        return null;
    }

Usage Example

<?php

require_once '../asana.php';
// See class comments and Asana API for full info
$asana = new Asana(array('apiKey' => 'XXXXXXXXXXXXXXXXXXX'));
// Your API Key, you can get it in Asana
$workspaceId = 'XXXXXXXXXXXXXXXXXXX';
// The workspace where we want to create our task, take a look at getWorkspaces() method.
// First we create the task
$asana->createTask(array('workspace' => $workspaceId, 'name' => 'Hello World!', 'assignee' => '*****@*****.**'));
// As Asana API documentation says, when a task is created, 201 response code is sent back so...
if ($asana->hasError()) {
    echo 'Error while trying to connect to Asana, response code: ' . $asana->responseCode;
    return;
}
$result = $asana->getData();
if (isset($result->id)) {
    echo $result->id;
    // Here we have the id of the task that have been created
}
All Usage Examples Of Asana::getData