我提出了以下與Google Tasks API配合使用的代碼,但它只顯示從gmail.com獲得的結果。任何不適用的自定義Google Apps域。有人知道我應該使用Google Apps Domain Tasks API的網址嗎?如何從谷歌Google Apps域的Google 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>▬▬▬";
?>