繁体   English   中英

显示用户的 Google 日历 (PHP)

[英]Display user's Google Calendar (PHP)

我制作了一个应用程序,用户可以通过表单在他的 Google 日历中添加事件。 我使用 Oauth2 身份验证和 Google 日历 API(在 PHP 中)。 现在我想在用户连接到他的 Google 帐户时显示用户的日历。 我可以使用 iframe 或其他解决方案来做到这一点吗?

实际上 CalendarID 是用户的邮件。 所以,它有效:

$oauth2 = new Google_Service_Oauth2($client);
$userinfo = $oauth2->userinfo->get();
$emailUser = $userinfo->getEmail();
print_r($emailUser);

$emailUserCal=str_replace ('@','%40',$emailUser);
print_r($emailUserCal);

我们需要将 url 中的 '@' 替换为 '%40'。

以我的形式:

<?php echo '<iframe src="https://www.google.com/calendar/embed?height=600&amp;wkst=1&amp;bgcolor=%23FFFFFF&amp;src=' . $emailUserCal . '&amp;color=%232952A3&amp;ctz=Europe%2FParis" style=" border-width:0 " width="800" height="600" frameborder="0" scrolling="no"></iframe>' ?>

只需传递您要显示日历的用户邮件 ID。

在 PHP 中:

$userEmail = "test@gmail.com";

<iframe src="https://www.google.com/calendar/embed?height=600&amp;wkst=1&amp;bgcolor=%23FFFFFF&amp;src=' . $userEmail . '&amp;color=%232952A3&amp;ctz=Europe%2FParis" style=" border-width:0 " width="100%" height="600" frameborder="0" scrolling="no"></iframe>

在 Js 中:

let userEmail = "test@gmail.com";

 let calendarIfram = '<iframe src="https://www.google.com/calendar/embed?height=600&amp;wkst=1&amp;bgcolor=%23FFFFFF&amp;src=' + userEmail + '&amp;color=%232952A3&amp;ctz=Europe%2FParis" style=" border-width:0 " width="100%" height="600" frameborder="0" scrolling="no"></iframe>';

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM