显示用户的Google日历(PHP)

时间:2015-03-23 13:10:49

标签: php google-calendar-api

我已经制作了一个应用程序,用户可以通过表单在Google日历中添加活动。我使用Oauth2身份验证和Google Calendar API(在PHP中)。 现在,当用户与其Google帐户关联时,我想显示用户的日历。我可以使用iframe或其他解决方案吗?

2 个答案:

答案 0 :(得分:0)

事实上,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);

我们需要更换' @'通过'%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>' ?>

答案 1 :(得分:0)

只需传递您要显示日历的用户邮件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>';
相关问题