How to access any other's google calendar using google php api -


i need access other user's google calendar freebusy using google php api. can 1 me step step process implement that. have checked https://developers.google.com/google-apps/calendar/v3/reference/freebusy/query#response nothing fruitful got.

my approach

session_start();  require_once ('libraries/google/autoload.php');  $client = new google_client(); $client->setclientid($client_id); $client->setclientsecret($client_secret); $client->setredirecturi($redirect_uri); $client->addscope("email"); $client->addscope("profile"); $client->addscope(google_service_calendar::calendar); $client->addscope(google_service_calendar::calendar_readonly); $client->setaccesstype('offline');   $service = new google_service_oauth2($client);  if (isset($_get['code'])) {   $client->authenticate($_get['code']);   $_session['access_token'] = $client->getaccesstoken();   header('location: ' . filter_var($redirect_uri, filter_sanitize_url));   exit; }  /************************************************   if have access token, can make   requests, else generate authentication url.  ************************************************/ if (isset($_session['access_token']) && $_session['access_token']) {   $client->setaccesstoken($_session['access_token']); } else {   $authurl = $client->createauthurl(); }  $client->setapplicationname("my calendar"); //don't think matters $client->setdeveloperkey($api_key); //get @ at developers.google.com $cal = new google_service_calendar($client); $calendarid = 'any_other_user_email@gmail.com';  $freebusy_req = new google_service_calendar_freebusyrequest();  $freebusy_req->settimemin($mintime); $freebusy_req->settimemax($maxtime); $freebusy_req->settimezone($time_zone); $freebusy_req->setcalendarexpansionmax(10); $freebusy_req->setgroupexpansionmax(10);  $item = new google_service_calendar_freebusyrequestitem(); $item->setid($email);  $freebusy_req->setitems(array($item));  $query = $cal->freebusy->query($freebusy_req);  $response_calendar = $query->getcalendars(); $busy_obj = $response_calendar[$email]->getbusy(); 

but getting blank in terms of free busy.

just make sure calendar public, try google calendar freebusy method. work.


Comments

Popular posts from this blog

java - Run spring boot application error: Cannot instantiate interface org.springframework.context.ApplicationListener -

python - pip wont install .WHL files -

Excel VBA "Microsoft Windows Common Controls 6.0 (SP6)" Location Changes -