【发布时间】:2011-06-21 10:59:09
【问题描述】:
我编写了以下代码,可与 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>▬▬▬";
?>
【问题讨论】:
标签: google-api gdata-api google-apps gdata