如何从Google Apps域的Google Tasks API中获取任务?

时间:2011-05-16 11:56:57

标签: google-api gdata-api google-apps gdata

我制作了以下与Google Tasks API一起使用的代码,但它只显示来自gmail.com的结果。它不适用于任何自定义Google Apps域。有谁知道我应该用于Google Apps Domain Tasks API的网址?

代码:

<?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;";



?>

2 个答案:

答案 0 :(得分:1)

答案 1 :(得分:0)

我正在使用gafyd,它对我有用。您的域名是否已迁移到新系统?