Google calendar api Google Calendar PHP API v3中的ical()类需要哪个PHP脚本文件
我正在生成的PHP脚本中出现错误: 致命错误:在第74行的/home/abc/public_html/app/mods/googleCalendar_3.0/cache_events.php中找不到类“ical” 以下是我的脚本文件中的一个片段:Google calendar api Google Calendar PHP API v3中的ical()类需要哪个PHP脚本文件,google-calendar-api,google-api-php-client,Google Calendar Api,Google Api Php Client,我正在生成的PHP脚本中出现错误: 致命错误:在第74行的/home/abc/public_html/app/mods/googleCalendar_3.0/cache_events.php中找不到类“ical” 以下是我的脚本文件中的一个片段: define('CLIENT_ID', 'ASDLJJLDSJLASDJLajdl;jdsljkASD;LKJASDLKJASD.apps.googleusercontent.com'); require_once('autoload.php
define('CLIENT_ID', 'ASDLJJLDSJLASDJLajdl;jdsljkASD;LKJASDLKJASD.apps.googleusercontent.com');
require_once('autoload.php'); // 2014-11-24 part of /usr/local/lib/php/google-api-php-client
require_once('/usr/local/lib/php/google-api-php-client/src/Google/Client.php'); // 2014-11-25
require_once('/usr/local/lib/php/google-api-php-client/src/Google/Service/Calendar.php'); // 2014-11-25
$ical = new ical('https://www.google.com/calendar/ical/CLIENT-ID/public/basic.ics');
$eventListArray = array_filter($ical -> events(), "locationfilter");
$eventCount = count($eventListArray);
print_r($eventListArray); echo "<br>";
echo "Event Count:" . $eventCount;echo "<br>";
exit;
define('CLIENT_ID','asdljldsjlasdjlajdl;jdsljkASD;LKJASDLKJASD.apps.googleusercontent.com');
需要_once('autoload.php');//2014年11月24日/usr/local/lib/php/google api php客户端的一部分
require_once('/usr/local/lib/php/google-api-php-client/src/google/client.php');//2014-11-25
需要_once('/usr/local/lib/php/google-api-php-client/src/google/Service/Calendar.php');//2014-11-25
$ical=新ical($ical)https://www.google.com/calendar/ical/CLIENT-ID/public/basic.ics');
$eventListArray=array_filter($ical->events(),“locationfilter”);
$eventCount=计数($eventListArray);
打印($eventListArray);回声“
”;
回显“事件计数:”$事件计数;回声“
”;
出口
我只是试图检索我的公共日历中的所有事件
注:
日历可公开查看
为了确保安全,我在其中添加了我的Auth&API的>凭据>服务帐户>电子邮件地址如果你想使用服务帐户,你的代码可能会出错。我无法测试此代码我的本地Web服务器正在运行,但它应该已关闭。您可能需要查看
$service->Events->list()代码>部分这是一种猜测。确保您已将服务帐户电子邮件地址作为用户添加到相关日历中,并且该地址应能正常工作
session_start();
require_once 'Google/Client.php';
require_once 'Google/Service/Calendar.php';
/************************************************
The following 3 values an befound in the setting
for the application you created on Google
Developers console. Developers console.
The Key file should be placed in a location
that is not accessable from the web. outside of
web root. web root.
In order to access your GA account you must
Add the Email address as a user at the
ACCOUNT Level in the GA admin.
************************************************/
$client_id = '1046123799103-nk421gjc2v8mlr2qnmmqaak04ntb1dbp.apps.googleusercontent.com';
$Email_address = '1046123799103-nk421gjc2v8mlr2qnmmqaak04ntb1dbp@developer.gserviceaccount.com';
$key_file_location = '629751513db09cd21a941399389f33e5abd633c9-privatekey.p12';
$client = new Google_Client();
$client->setApplicationName("Client_Library_Examples");
$key = file_get_contents($key_file_location);
// seproate additional scopes with a comma
$scopes ="https://www.googleapis.com/auth/calendar";
$cred = new Google_Auth_AssertionCredentials(
$Email_address,
array($scopes),
$key
);
$client->setAssertionCredentials($cred);
if($client->getAuth()->isAccessTokenExpired()) {
$client->getAuth()->refreshTokenWithAssertion($cred);
}
$service = new Google_Service_Calendar($client);
// you should only need to do this once print this and you will
// find the calendarId for the one you are looking for.
$calendars = $service->calendarList->list();
$events = $service->events->list($yourCalendarID);
注意:你所需要的是谷歌目录,你可以删除上面所有你不需要的东西。这段代码是从我仅有的教程中编辑出来的,教程中显示了这一点 一,。打印$服务只需检查其连接。2.尝试将其更改为$service->events->list();可能是小写,只是检查了客户端库。等等,这不起作用。您需要日历Id。只需编辑您的日历列表,就必须使用日历列表来查找Id。我不认为MY-CAL是更像“”的日历Id311gpgricpq0mjpi567806321g@group.calendar.google.com“嘿,你猜怎么着……我打印了$events和low,看哪,events出现了。谢谢……我是在开玩笑。我知道谷歌不会这么做。他们忙于反对和发布,没有明确的方式让人们理解如何使用和实现他们发布的内容。我们这些“懒汉”必须等着像你这样的人发光。再次感谢。