Search code examples
google-apigdata-apigoogle-appsgdata

How to grab tasks from Google Tasks API for Google Apps Domains?


I made the following code that works with the Google Tasks API but it only shows result when its from gmail.com. Any custom Google Apps domain it doesn't work for. Does anyone know the url I should use for the Google Apps Domain Tasks API?

Code:

<?php
session_start();

//load libs
require_once "include/google-api-php-client/src/apiClient.php";
require_once "include/google-api-php-client/src/contrib/apiTasksService.php";

//load api
$apiClient = new apiClient();
$service = new apiTasksService($apiClient);

//authenticate
if (isset($_SESSION['oauth_access_token'])) {
  $apiClient->setAccessToken($_SESSION['oauth_access_token']);
} else {
  $token = $apiClient->authenticate();
  $_SESSION['oauth_access_token'] = $token;
}

//get token
//echo "token: ".$_SESSION['oauth_access_token']."<br />";

//get list
$taskLists = $service->listTasklists();

foreach ($taskLists['items'] as $taskList) {
  echo $taskList['title'] . " - " . $taskList['id'] . "<br />";
}


//get list items
echo "<ul>";
$tasks = $service->listTasks('@default');

foreach($tasks['items'] as $task) {
    $title = $task['title'];
    echo "<li>$title</li>";
}
echo "</ul>&#9644;&#9644;&#9644;";



?>

Solution

  • This particular issue is being tracked here: https://code.google.com/apis/tasks/forum.html?place=topic%2Fgoogle-tasks-api%2FCVyxwz-Z9Rg%2Fdiscussion