Google 日历 API 键无效
Google Calendar API key is not working
所以从这里访问:https://console.developers.google.com/project
在我的项目中,我刚刚启用了日历 API。
现在我正在尝试执行以下操作:(出于显而易见的原因隐藏了我的密钥)
$client = new Zend_Http_Client('https://www.googleapis.com/calendar/v3/calendars/en.usa#holiday@group.v.calendar.google.com/events');
$client->setParameterGet(array(
'key' => '########################',
));
$feed = $client->request()->getBody();
echo "<pre>";
print_r($feed);
exit;
但是这样做会给我以下错误:
{
"error": {
"errors": [
{
"domain": "global",
"reason": "required",
"message": "Login Required",
"locationType": "header",
"location": "Authorization"
}
],
"code": 401,
"message": "Login Required"
}
}
我做错了什么?我正在使用服务器 API 密钥。
几天前我遇到了类似的问题。在 www.google.com/calendar/ -> 我的日历 -> 日历设置和日历地址中查看您的日历 ID。 ID 应包含字母和数字,而不是电子邮件地址。
我想通了。日历 ID 必须经过 urlencoded。
所以从这里访问:https://console.developers.google.com/project
在我的项目中,我刚刚启用了日历 API。
现在我正在尝试执行以下操作:(出于显而易见的原因隐藏了我的密钥)
$client = new Zend_Http_Client('https://www.googleapis.com/calendar/v3/calendars/en.usa#holiday@group.v.calendar.google.com/events');
$client->setParameterGet(array(
'key' => '########################',
));
$feed = $client->request()->getBody();
echo "<pre>";
print_r($feed);
exit;
但是这样做会给我以下错误:
{
"error": {
"errors": [
{
"domain": "global",
"reason": "required",
"message": "Login Required",
"locationType": "header",
"location": "Authorization"
}
],
"code": 401,
"message": "Login Required"
}
}
我做错了什么?我正在使用服务器 API 密钥。
几天前我遇到了类似的问题。在 www.google.com/calendar/ -> 我的日历 -> 日历设置和日历地址中查看您的日历 ID。 ID 应包含字母和数字,而不是电子邮件地址。
我想通了。日历 ID 必须经过 urlencoded。