Hello!
I’m creating my custom Dashboard that mixes Asana, Time, and Invoices, and I’m creating a database of a small piece of tasks.
I’ve made a script that recurres projects not archive and then tasks in project. But it gets this error:
offset: Your pagination token has expired.
This is my code in PHP:
foreach ( $asana_projects as $project ) {
echo 'Project: ' . $project['gid'] . ' Name: ' . $project['name'] . PHP_EOL;
echo 'Tasks: ';
// API Pagination.
$offset = null;
do {
$options_call = array(
'project' => $project['gid'],
'opt_fields' => 'gid,assignee_gid,created_at,completed,completed_at,due_at,due_on,modified_at,name,projects',
'limit' => BD_LIMIT_API,
);
if ( $offset ) {
$options_call['offset'] = $offset;
}
$tasks = get_asana(
BD_ASANA_API,
null,
'tasks',
$options_call
);
if ( ! empty( $tasks ) ) {
foreach ( $tasks as $task ) {
if ( isset( $task['gid'] ) ) {
save_task_db( $task['gid'] );
echo $task['gid'] . ', ';
} elseif ( isset( $task['offset'] ) ) {
$offset = $task['offset'];
}
}
}
} while ( $offset != null );
echo PHP_EOL;
}
Get_asana is a function that connects to Asana API.
What am I doing wrong?
Thanks.