Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/264.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Google Api v3通过监视获取修改事件(web_hook)_Php_Calendar_Google Api_Google Calendar Api_Webhooks - Fatal编程技术网

Php Google Api v3通过监视获取修改事件(web_hook)

Php Google Api v3通过监视获取修改事件(web_hook),php,calendar,google-api,google-calendar-api,webhooks,Php,Calendar,Google Api,Google Calendar Api,Webhooks,我使用谷歌Api v3添加和修改谷歌事件。 除了我无法获得在谷歌事件中所做的更改外,大多数事情都运行良好 我使用以下代码: require_once 'google-api-php-client/src/Google/Client.php'; require_once 'google-api-php-client/src/Google/Service/Analytics.php'; require_once 'google-api-php-client/src/Google/Service/Ca

我使用谷歌Api v3添加和修改谷歌事件。 除了我无法获得在谷歌事件中所做的更改外,大多数事情都运行良好 我使用以下代码:

require_once 'google-api-php-client/src/Google/Client.php';
require_once 'google-api-php-client/src/Google/Service/Analytics.php';
require_once 'google-api-php-client/src/Google/Service/Calendar.php';

$client_id = 'my-client_id';  // works without this
$Email_address = 'my-Email_address';
$key_file_location = 'my-key_file_location.p12';


$client = new Google_Client();
$client->setApplicationName("app-name"); // works without random names
$key = file_get_contents($key_file_location);

$scopes = array('https://www.googleapis.com/auth/calendar', 'https://www.googleapis.com/auth/calendar.readonly');


$cred = new Google_Auth_AssertionCredentials($Email_address, $scopes , $key);
$client->setAssertionCredentials($cred);

if ($client->getAuth()->isAccessTokenExpired())
{
    $client->getAuth()->refreshTokenWithAssertion($cred);
}


$service = new Google_Service_Calendar($client);

$cals = $service->calendarList->listCalendarList();
$event = new Google_Service_Calendar_Event();

$event->setSummary('04/03 appointment -1');
$start = new Google_Service_Calendar_EventDateTime();
$start->setDateTime('2015-03-27T11:00:00.000-00:00');
$start->setTimeZone('Asia/Calcutta');
$event->setStart($start);
$end = new Google_Service_Calendar_EventDateTime();
$end->setDateTime('2015-03-27T11:25:00.000-00:00');
$end->setTimeZone('Asia/Calcutta');
$event->setEnd($end);
$attendee1 = new Google_Service_Calendar_EventAttendee();
$attendee1->setEmail('myemail@gmail.com'); 
$attendees = array($attendee1);
$event->attendees = $attendees;
$recurringEvent = $service->events->insert('randome-id@group.calendar.google.com', $event);
echo $dynamicId =  $recurringEvent->getId();

$events = $service->events->listEvents('randome-id@group.calendar.google.com');

echo "<br>start - into web hoot <br>";

$service = new Google_Service_Calendar($client);
$channel =  new Google_Service_Calendar_Channel($client);
$channel->setId($dynamicId);
$channel->setType('web_hook');

echo '<br>';
echo $url = 'https://mydomain.com.return.php';
$channel->setAddress($url);

$timetoExpire = time()+3600000;


$optParams = array('ttl' => $timetoExpire);
$channel->setParams($optParams);

try
{
    echo "<br>";
    $watchEvent = $service->events->watch('randome-id@group.calendar.google.com', $channel);
    print_r($watchEvent);
    echo "<br>hook applied<br>";
}
catch(Exception $e)
{
    echo $e;
    echo "web hook not working<br />.";
}

echo "<br>end";

exit;

请帮助我了解如何在goggle Calendar中获取修改后的活动日期,提前感谢

您的HTTPS地址是否在web服务器上安装了有效的SSL证书??其他明智的谷歌日历API将无法发送通知。另外,您的通知频道的监视请求是否成功?是的。当我修改一些东西时,谷歌会回复return.php页面,即:mydomain.com/return.php。当我尝试将return.php打印到文本文件时,它不会显示任何内容。我不确定如何获取修改后的事件数据下面的文档提到了如何进行增量同步不确定如何在php changes=service.events().list(“我的_calendar@my-host.com”).setUpdatedMin(lastSynchonizationTime).execute();
[resourceId] =7U94nhlXTXH_tK13-5JIrZTBWU0
[resourceUri] =https://www.googleapis.com/calendar/v3/calendars/randome-id@group.calendar.google.com/events?alt=json