Fix for new version of api client.
This commit is contained in:
33
calendar.php
33
calendar.php
@@ -110,7 +110,7 @@ if ($bHasContactsCalendar) {
|
|||||||
|
|
||||||
// Get contact id from event
|
// Get contact id from event
|
||||||
$aPreferences = $oGadget->getPreferences();
|
$aPreferences = $oGadget->getPreferences();
|
||||||
if (!isset($aPreferences['goo.contactsContactId']) ) {
|
if (!isset($aPreferences['goo.contactsContactId'])) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$sContactId = $aPreferences['goo.contactsContactId'];
|
$sContactId = $aPreferences['goo.contactsContactId'];
|
||||||
@@ -128,29 +128,28 @@ if ($bHasContactsCalendar) {
|
|||||||
if (!isset($aContacts[$sContactId])) {
|
if (!isset($aContacts[$sContactId])) {
|
||||||
// Get contact details from contact id
|
// Get contact details from contact id
|
||||||
$sUrl = sprintf('https://www.google.com/m8/feeds/contacts/%s/full/%s?v=3.0', CONTACTS_USER_EMAIL, $sContactId);
|
$sUrl = sprintf('https://www.google.com/m8/feeds/contacts/%s/full/%s?v=3.0', CONTACTS_USER_EMAIL, $sContactId);
|
||||||
$oHttpRequest = new Google_Http_Request($sUrl);
|
$oHttpClient = $oClient->authorize();
|
||||||
$oHttpRequest = $oAuth->sign($oHttpRequest);
|
$oHttpRequest = new GuzzleHttp\Psr7\Request('GET', $sUrl);
|
||||||
$aResponse = $oClient->getIo()->executeRequest($oHttpRequest);
|
$sResponse = $oHttpClient->send($oHttpRequest)->getBody()->getContents();
|
||||||
|
|
||||||
// Parse XML to fetch birthday
|
// Parse XML to fetch birthday
|
||||||
$sXml = str_replace(array('gd:', 'gContact:'), null, $aResponse[0]);
|
$sXml = str_replace(array('gd:', 'gContact:'), null, $sResponse);
|
||||||
$oXml = simplexml_load_string($sXml);
|
$oXml = simplexml_load_string($sXml);
|
||||||
$aBirthday = (array) $oXml->birthday->attributes();
|
$sDate = ((array) $oXml->birthday)['@attributes']['when'];
|
||||||
$sDate = current(current($aBirthday));
|
|
||||||
|
|
||||||
// Save birthday date
|
// Save birthday date
|
||||||
$aContacts[$sContactId][CALENDAR_BIRTHDAY_NAME] = $sDate;
|
$aContacts[$sContactId][CALENDAR_BIRTHDAY_NAME] = $sDate;
|
||||||
|
|
||||||
// Iterate all events of contact
|
// Iterate all events of contact
|
||||||
$aEvents = (array) $oXml->event;
|
#$aEvents = (array) $oXml->event;
|
||||||
while (($oEvent = next($aEvents)) !== false) {
|
#while (($oEvent = next($aEvents)) !== false) {
|
||||||
$aEvent = (array) $oEvent;
|
# $aEvent = (array) $oEvent;
|
||||||
$sEvent = current(current($aEvent));
|
# $sEvent = current(current($aEvent));
|
||||||
$sDate = current(current(next($aEvent)));
|
# $sDate = current(current(next($aEvent)));
|
||||||
|
#
|
||||||
// Save other event date
|
# // Save other event date
|
||||||
$aContacts[$sContactId][$sEvent] = $sDate;
|
# $aContacts[$sContactId][$sEvent] = $sDate;
|
||||||
}
|
#}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get date of current event
|
// Get date of current event
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"require": {
|
"require": {
|
||||||
"google/apiclient": "1.1.2"
|
"google/apiclient": "2.2.3"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -5,7 +5,7 @@ define('CLIENT_SECRET', '');
|
|||||||
define('REDIRECT_URI', sprintf('http://%s%s', $_SERVER['HTTP_HOST'], $_SERVER['PHP_SELF']));
|
define('REDIRECT_URI', sprintf('http://%s%s', $_SERVER['HTTP_HOST'], $_SERVER['PHP_SELF']));
|
||||||
|
|
||||||
// Calendar preferences
|
// Calendar preferences
|
||||||
define('CONTACTS_CALENDAR_ID', '#contacts@group.v.calendar.google.com');
|
define('CONTACTS_CALENDAR_ID', 'addressbook#contacts@group.v.calendar.google.com');
|
||||||
define('TARGET_CALENDAR_SUMMARY', 'Birthdays');
|
define('TARGET_CALENDAR_SUMMARY', 'Birthdays');
|
||||||
define('CALENDAR_BIRTHDAY_NAME', 'birthday');
|
define('CALENDAR_BIRTHDAY_NAME', 'birthday');
|
||||||
define('CONTACTS_USER_EMAIL', 'default');
|
define('CONTACTS_USER_EMAIL', 'default');
|
||||||
|
|||||||
Reference in New Issue
Block a user