php


Google Calendar API freeBusy multipple calendars


I have successfully been able to get freeBusy data from a single calendar using PHP, but when I try to get multipple calendars in one call as suggested by Google:
"items":
[
{
"id": string
}
]
I cant' seem to use PHP to make the array object correct as I have tried the few examples on StackOverflow and my general skills on handling PHP arrays without success. The purpose is to have multipple calendar id's as an array, an then loop throug that array to make the request object correct according to Google API. Has anyone seen the same problem and actually tried to use multipple calendar id's. I have a slight feeling that this might be a bug in the PHP SDK for Google Calendar. Can anyone point in any direction? This is my working code for a single calendar id:
$client = new Google_Client();
$client->setAuthConfig("credentials/oauth-credentials.json");
$client->setScopes('https://www.googleapis.com/auth/calendar');
$client->addScope(Google_Service_Calendar::CALENDAR);
$client->useApplicationDefaultCredentials();
$cal = new Google_Service_Calendar($client);
$calendarId = 'narvik.kommune.no_2d37393134#resource.calendar.google.com';
//$calendarId = array('narvik.kommune.no_37383343730#resource.calendar.google.com','narvik.kommune.no_2d1383134#resource.calendar.google.com');
$freebusy_req = new Google_Service_Calendar_FreeBusyRequest();
$freebusy_req->setTimeMin(date(DateTime::ATOM, strtotime('2017-05-01T08:00:00.000Z')));
$freebusy_req->setTimeMax(date(DateTime::ATOM, strtotime('2017-05-19T17:00:00.000Z')));
$freebusy_req->setTimeZone($timezone);
$freebusy_req->setCalendarExpansionMax(10);
$freebusy_req->setGroupExpansionMax(10);
$item = new Google_Service_Calendar_FreeBusyRequestItem();
$item->setId($calendarId);
$freebusy_req->setItems(array($item));
$query = $cal->freebusy->query($freebusy_req);
$response_calendar = $query->getCalendars();
$busy_obj = $response_calendar[$calendarId]->getBusy();
and this is the resulting print_r($busy_obj);
Array
(
[0] => Google_Service_Calendar_TimePeriod Object
(
[end] => 2017-05-01T14:50:00Z
[start] => 2017-05-01T09:00:00Z
[internal_gapi_mappings:protected] => Array
(
)
[modelData:protected] => Array
(
)
[processed:protected] => Array
(
)
)

Related Links

easy way to send a json array in a single variable to a view codeigniter
image not being displayed in android
mysqli_stmt::bind_result(): Number of bind variables doesn't match number of fields in prepared statement in
How to make processes run in parallel and script to wait all of them to finish in PHP
PHP Object Oriented array not being printed
Phalcon 2 vs Phalcon 3 instantiate model
How do i fetch search result of two websites on my page?
Multiple vars assignment in one sentence in PHP
Add time offset from GMT to Unix timestamp PHP
Need tips to how this PHP function won't work
Wordpress: Remove site info in functions.php
Easy way to parse array values [duplicate]
Nginx Configuration - Upstream - Backup Server
How to store image in mysql table using php? [duplicate]
How to load balance a request to external server?
Working with wordpress using laravel valet, unable to increase maximum upload limit

Categories

HOME
jboss
flask
events
yii
xcode8.1
message-queue
theano
visual-studio-2010
lvm
openflow
dji-sdk
angular-meteor
phpseclib
stack-overflow
phpstorm-2017.1
chromecast
jquery-select2-4
ex
max-msp-jitter
user-defined-types
spam
jest
opam
gitkraken
backendless
high-availability
hevc
actframework
epplus
seafile-server
knights-tour
private-key
shapeless
cloveretl
apptentive
grails-2.5
text-decorations
widestring
python-sounddevice
windows-store
grails-spring-security
jacoco-maven-plugin
uipickerview
classnotfoundexception
angular-datatables
yoast
jshint
gtk#
lvalue
google-shopping-api
cefpython
yui3
apple-configurator
xcopy
servicestack-bsd
json-spirit
helm
mousehover
astropy
blank-line
uitest
roxygen2
textscan
r.java-file
subview
nhibernate-criteria
nesper
qt5.4
jquery-mobile-flipswitch
otl
category-theory
rpg
redpitaya
zend-search-lucene
compiler-flags
acitree
ldif
insertion
bcdedit
ui-design
android-authenticator
system-requirements
idispatch
stretch
arrow
sfinae
first-class
server-name
algol68
django-apps
suphp
principles
self-tracking-entities
yahoo-maps
google-translator-toolkit

Resources

Encrypt Message