问题描述
我可以问您是否有人可以回答我有关Google Calendar API的问题?我已经生成了凭据,并且在localhost上工作正常。我只想返回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,);
非常感谢
亚历克斯
解决方法
尝试删除下面的代码,据我所知此代码仅用于本地主机,以强制使用https。
$gazza = new GuzzleHttp\Client([
'verify' => './cacert.pem'
]);