我正在尝试使用Google API v3访问一个Google日历,并根据此处的文档:http://code.google.com/apis/calendar/v3/using.html#intro和here:https:// code.google.com/apis/console/,我需要的解决方案是"简单API访问"和"服务器应用程序密钥(带IP锁定)".
现在,当我使用以下代码创建页面时:
session_start();
require_once 'fnc/google-api-php-client/src/apiClient.php';
require_once 'fnc/google-api-php-client/src/contrib/apiCalendarService.php';
$apiClient = new apiClient();
$apiClient->setUseObjects(true);
$service = new apiCalendarService($apiClient);
if (isset($_SESSION['oauth_access_token'])) {$apiClient->setAccessToken($_SESSION['oauth_access_token']);
} else {
$token = $apiClient->authenticate();
$_SESSION['oauth_access_token'] = $token;
}
Run Code Online (Sandbox Code Playgroud)
在我的"config.php"文件中,我只添加了我的开发键(代替"X"):
global $apiConfig;
$apiConfig = array(
// True if objects should be returned by the service classes.
// False if associative arrays should be returned (default behavior).
'use_objects' => false,
// The application_name is included in the User-Agent HTTP header.
'application_name' => …Run Code Online (Sandbox Code Playgroud)