【发布时间】:2020-09-23 15:23:15
【问题描述】:
请问有没有人可以回答我有关 Google Calendar API 的问题?我已经生成了凭据,并且在本地主机上它工作得很好。我只想返回 100 个即将发生的事件($service->events->listEvents($calendarId, $optParams) 但生产中的相同代码不起作用,它返回 500 Internal Server Error 特别是在这段代码上。任何建议如何继续?
这是一段代码,它在第一个注释行中断
<?php
require './vendor/autoload.php';
$client = new Google_Client();
$gazza = new GuzzleHttp\Client([
'verify' => './cacert.pem'
]);
$client->setApplicationName('Google Calendar API PHP Quickstart');
$client->setScopes(Google_Service_Calendar::CALENDAR_READONLY);
$client->setAuthConfig('./credentials-calendar-old.json');
$client->setAccessType('offline');
$tokenPath = 'token.json';
if (file_exists($tokenPath)) {
$accessToken = json_decode(file_get_contents($tokenPath), true);
$client->setAccessToken($accessToken);
}
$service = new Google_Service_Calendar($client);
$calendarId = 'primary';
$optParams = array(
'maxResults' => 1000,
'orderBy' => 'startTime',
'singleEvents' => true,
'timeMin' => date('c'),
);
$results = $service->events->listEvents($calendarId, $optParams);
$events = $results->getItems();
// Print the next 10 events on the user's calendar.
$calendarId = 'primary';
$optParams = array(
'maxResults' => 1000,
'orderBy' => 'startTime',
'singleEvents' => true,
'timeMin' => date('c'),
);
非常感谢,
亚历克斯
【问题讨论】:
-
这篇文章需要更多信息,500服务器错误意味着函数以崩溃结束。崩溃可能是从类型错误到调用外部服务的错误,你需要找到你的代码被破坏的地方。
-
我发布了一段代码,给我 500 的 URL 是 www.pedagogickydiar.com/kalendar
-
您的代码中有错误:[错误] 视口参数键“minimal-ui”无法识别和忽略。 (日历,第 1 行)[错误] TypeError:null 不是对象(评估'document.getElementById('ypembedcontainer').style')yp_emb_resp_check(yp_r_iframe.js:9)全局代码(yp_r_iframe.js:13)[错误] 未处理的承诺拒绝:语法错误:字符串与预期的模式不匹配。 (匿名函数) promiseReactionJob [Error] TypeError: null is not an object (evalating 'document.getElementById('ypembedcontainer').style') yp_emb_resp_check (yp_r_iframe.js:9)