Php 我可以使用Google API授权服务帐户嵌入日历iframe吗?

Php 我可以使用Google API授权服务帐户嵌入日历iframe吗?,php,iframe,google-calendar-api,google-api-php-client,Php,Iframe,Google Calendar Api,Google Api Php Client,我正在尝试使用带有日历id的嵌入代码将Google日历嵌入iframe中。我已创建了一个服务帐户,并授予该帐户访问相关日历的权限 我可以使用GoogleAPI客户端成功地验证服务帐户,并且可以从日历中获取事件。但是,我不知道如何进行身份验证以便显示iframe require_once __DIR__ . '/googleapi/vendor/autoload.php'; $client = new Google_Client(); $client->setApplicationName

我正在尝试使用带有日历id的嵌入代码将Google日历嵌入iframe中。我已创建了一个服务帐户,并授予该帐户访问相关日历的权限

我可以使用GoogleAPI客户端成功地验证服务帐户,并且可以从日历中获取事件。但是,我不知道如何进行身份验证以便显示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>`
require\u once\uuuuu DIR\uuuuuuu.'/googleapi/vendor/autoload.php';
$client=新的Google_客户端();
$client->setApplicationName('Google日历API PHP');
$client->setScopes(谷歌服务日历::日历只读);
$client->setAuthConfig('my-credentials.json');
$client->setAccessType('offline');
$service=新谷歌服务日历($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>

就像您试图在iframe中运行google日历应用程序一样。这是行不通的,因为你无法对其进行身份验证,我认为谷歌不会允许他们从iframe登录

<iframe src="https://yourcalendar.application.dk/awsomapp.php" style="border: 0" width="800" height="600" frameborder="0" scrolling="no"></iframe>
你应该做什么

<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>
您应该按照自己的意愿设计日历显示,然后将应用程序放在iframe中

<iframe src="https://yourcalendar.application.dk/awsomapp.php" style="border: 0" width="800" height="600" frameborder="0" scrolling="no"></iframe>

服务帐户只会让你访问数据,而不会让你通过iframe运行谷歌日历网站

<iframe src="https://yourcalendar.application.dk/awsomapp.php" style="border: 0" width="800" height="600" frameborder="0" scrolling="no"></iframe>