我需要使用Google Calendar API从我的日历中检索数据。
我创建了我的应用程序并创建了我的服务器API密钥。我输入了我的IP地址(因为我在我的测试服务器上运行)。
之后,我创建了一个简单的PHP文件,该文件使用Curl从Google的服务器请求数据。文件看起来像这样:
$ch = curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch,CURLOPT_URL,"https://www.googleapis.com/calendar/v3/calendars/myCalendarEmail@gmail.com/events?maxResults=15&key={My Key}");
$result=curl_exec($ch);
echo $result;
然而,当执行此操作时,我收到此JSON(错误):
{
"error": {
"errors": [
{
"domain": "usageLimits",
"reason": "accessNotConfigured",
"message": "Access Not Configured. Please use Google Developers Console to activate the API for your project."
}
],
"code": 403,
"message": "Access Not Configured. Please use Google Developers Console to activate the API for your project."
}
}
我甚至在浏览器中输入了URL并获得了数据。经过几个小时的乱搞,我的浏览器返回相同的错误消息?我错过了什么,或者这只是一个错误?
这是API控制台给我的内容(这证明我说它在我的浏览器中工作而不是通过Curl)
答案 0 :(得分:0)
1)转到Google Developers Console 2)选择一个项目 3)在左侧边栏中,选择API& AUTH。在API列表中,请确保Google Calendar API的状态为“开启”。
答案 1 :(得分:0)
等待两天后,API响应开始起作用。这让我非常困惑,我真的期待Google提供更专业的API。我将继续观看此问题,直到有人发布此问题的真正解决方案。感谢。