【发布时间】:2019-02-04 10:20:25
【问题描述】:
我正在尝试使用带有日历 ID 的嵌入代码在 iframe 中嵌入 Google 日历。我创建了一个服务帐户并授予此帐户访问相关日历的权限。
我可以使用 google api 客户端成功验证服务帐户,并且可以从日历中获取事件。但是,我不知道如何进行身份验证,所以我可以显示 iframe。
require_once __DIR__ . '/googleapi/vendor/autoload.php';
$client = new Google_Client();
$client->setApplicationName('Google Calendar API PHP');
$client->setScopes(Google_Service_Calendar::CALENDAR_READONLY);
$client->setAuthConfig('my-credentials.json');
$client->setAccessType('offline');
$service = new Google_Service_Calendar($client);
?>
<iframe src="https://calendar.google.com/calendar/embed?src=calendarId&ctz=Europe%2FCopenhagen" style="border: 0" width="800" height="600" frameborder="0" scrolling="no"></iframe>`
结果只是一条消息,告诉我不允许我显示有问题的日历。
【问题讨论】:
标签: php iframe google-calendar-api google-api-php-client