已成功收到Google Calendar API Sync消息,但日历上没有通知更改PHP

I succesfully made a notification channel and received the first message (sync message) from the Google Calendar V3 API wich indicates that it can find my callback url etc. However, when i make changes to my calendar it wont give any notifications to my callback address.

x-Goog-Channel-ID:20fdedbf0-a845-11e3-1515e2-0800200c9a6671111
X-Goog-Channel-Expiration:Tue, 18 Mar 2014 15:48:34 GMT
X-Goog-Resource-State:sync
X-Goog-Message-Number:1
X-Goog-Resource-ID:WSX5G_51Ds8C7ZADf8Yemzhfego
X-Goog-Resource-URI:https://www.googleapis.com/calendar/v3/calendars/primary/events?alt=json

//Code from my request

session_start();
require_once(dirname(__FILE__)."/../includes/GoogleAPI/Google_Client.php");
require_once(dirname(__FILE__)."/../includes/GoogleAPI/contrib/Google_CalendarService.php");

$this->client = new Google_Client();
$this->client->setApplicationName("Test Application");

$this->client->setUseObjects(true);
if (isset($_SESSION['gapi_token'])) {

    $this->client->setAccessToken($_SESSION['gapi_token']);

} else {

    $key = file_get_contents(dirname(__FILE__). '/../includes/' . $this->key_file);
    $this->client->setAssertionCredentials( new Google_AssertionCredentials( $this->service_account_name , array( 'https://www.googleapis.com/auth/calendar' ), $key ));

    $_SESSION['gapi_token'] = $this->client->getAccessToken();
} 
$this->client->setClientId($this->client_id);
$cal = new Google_CalendarService($this->client);

$event = new Google_Event();
$event->setSummary('Appointment Test'); 
$event->setLocation('Amsterdam');     

/* Start Date
*/
$start = new Google_EventDateTime();
$start->setDateTime('2014-03-10T19:00:00.000+01:00'); 
$event->setStart($start);

/* Eind date
*/
$end = new Google_EventDateTime();
$end->setDateTime('2014-03-10T22:00:00.000+01:00'); 
$event->setEnd($end);

/* Voeg gasten toe
*/
$attendee1 = new Google_EventAttendee();
$attendee1->setEmail('[myemailadress]');
$attendees = array($attendee1);
$event->attendees = $attendees;

$createdEvent = $cal->events->insert('primary', $event);

echo "<pre>Event ID : '" . $this->client->getAccessToken() . "'</pre>";


//Part that creates the notification channel
$token = $this->client->getAccessToken();
$token_decode = json_decode($token);

$calendar = 'primary';
$url = sprintf("https://www.googleapis.com/calendar/v3/calendars/%s/events/watch", $calendar);
$fields = json_encode(array(
    'id'        => "20fdedbf0-a845-11e3-1515e2-0800200c9a6671111", 
    'type'      => "web_hook",
    'address'   => 'https://www.[mydomain].nl/apiero/calendar.push.notifications.php'
));

/* setup POST headers */
$headers[] = 'Content-Type: application/json';
$headers[] = 'Authorization: Bearer ' . $token_decode->access_token;

/* send POST request */
$channel = curl_init();
curl_setopt($channel, CURLOPT_HTTPHEADER, $headers);
curl_setopt($channel, CURLOPT_URL, $url);
curl_setopt($channel, CURLOPT_RETURNTRANSFER, true);
curl_setopt($channel, CURLOPT_POST, true);
curl_setopt($channel, CURLOPT_POSTFIELDS, $fields);
curl_setopt($channel, CURLOPT_CONNECTTIMEOUT, 2);
curl_setopt($channel, CURLOPT_TIMEOUT, 3);
$response = curl_exec($channel);
curl_close($channel);

$response = json_decode($response);

dump($response);

The dump above shows that it created the channel but like i said, after this i wont get any notifications when something is added or changed in the calendar (look below for the dump)

stdClass Object
(
[kind] => api#channel
[id] => 20fdedbf0-a845-11e3-1515e2-0800200c9a6671111
[resourceId] => WSX5G_51Ds8C7ZADf8Yemzhfego
[resourceUri] => https://www.googleapis.com/calendar/v3/calendars/primary/events?alt=json
[expiration] => 1395159757000
)

Can anyone help me with this issue?

Let me try. You need to replace 'primary' in your watch request with the actual email address you want to get notifications for so:

$calendar = 'youremailhere@google.com';// remove primary string that was here
$url =     sprintf("https://www.googleapis.com/calendar/v3/calendars/%s/events/watch", $calendar);
   $fields = json_encode(array(
   'id'        => "20fdedbf0-a845-11e3-1515e2-0800200c9a6671111", 
   'type'      => "web_hook",
   'address'   => 'https://www.[mydomain].nl/apiero/calendar.push.notifications.php'
));