How to fetch asana tasks with certain tag?

104 views Asked by At

I've created a little web application with some custom features and integrated into our backend.

Now, I would like to be able to filter all tasks by tag.

I have the following function:

public function getTasksByFilter($filter = array('assignee' => '', 'project' => '', 'workspace' => ''), array $opts = array()) {
    $url = '';
    $filter = array_merge(array('assignee' => '', 'project' => '', 'workspace' => ''), $filter);

    $url .= $filter['assignee'] !== '' ? '&assignee=' . $filter['assignee'] : '';
    $url .= $filter['project'] !== '' ? '&project=' . $filter['project'] : '';
    $url .= $filter['workspace'] !== '' ? '&workspace=' . $filter['workspace'] : '';

    if (count($opts) > 0) {
        $url .= '&' . http_build_query($opts);
    }
    if (strlen($url) > 0) {
        $url = '?' . substr($url, 1);
    }

    return $this->askAsana($this->taskUrl . $url);
}

How can I adjust this function to fetch only tasks with a certain tagId?

1

There are 1 answers

0
Andrew Noonan On BEST ANSWER

Tags is one of the parameters you may provide when querying for tasks. Treat it the same as you do the assignee, project, & workspace parameters you are already using to query.

You may also consider using the official PHP Asana Client to access the API in PHP.