/home/desid573/cf.desidrivers.com.au/google/api
NameSizeModeActions
cal/-0755rm
src/-0755rm
vendor/-0755rm
availability-calendar.zip1239260644editdlrm
availability.html00644editdlrm
calendarGet.php86700644editdlrm
calendarGetNew.php73600644editdlrm
client_secret.json4260644editdlrm
composer.json11740644editdlrm
composer.lock808370644editdlrm
credentials.json590644editdlrm
error_log51481620644editdlrm
getResults.php84920644editdlrm
key.json23490644editdlrm
results.json41050644editdlrm
Simple-Responsive-Availability-Calendar-Plugin-For-jQuery.zip47520644editdlrm
test.php1880644editdlrm
Edit: /home/desid573/cf.desidrivers.com.au/google/api/calendarGet.php (8670B)
setApplicationName('Chapel Farm Calendar'); // $client->setScopes(Google_Service_Calendar::CALENDAR); // $client->setAuthConfig('client_secret.json'); // $client->setAccessType('offline'); // $client->setPrompt('consent'); // // Load previously authorized credentials from a file. // $credentialsPath = expandHomeDirectory('credentials.json'); // if (file_exists($credentialsPath)) { // $accessToken = json_decode(file_get_contents($credentialsPath), true); // } else { // // Request authorization from the user. // $authUrl = $client->createAuthUrl(); // printf("Open the following link in your browser:\n%s\n", $authUrl); // print 'Enter verification code: '; // $authCode = "4/1AX4XfWgZYV9OC07VcH_7CjoB6WXnXa1ZLCgiosQZoE-FiGHWQZ_I7yKF81U"; // // Exchange authorization code for an access token. // $accessToken = $client->fetchAccessTokenWithAuthCode($authCode); // var_dump($accessToken); // error_log(json_encode($accessToken, true)); // // Store the credentials to disk. // if (!file_exists(dirname($credentialsPath))) { // mkdir(dirname($credentialsPath), 0700, true); // } // file_put_contents($credentialsPath, json_encode($accessToken)); // printf("Credentials saved to %s\n", $credentialsPath); // } // $client->setAccessToken($accessToken); // // Refresh the token if it's expired. // if ($client->isAccessTokenExpired()) { // error_log("getting expired token".$client->getRefreshToken()); // $client2 = $client->fetchAccessTokenWithRefreshToken($client->getRefreshToken()); // error_log(json_encode($client2, true)); // if($client2["error"] == "invalid_grant") { // error_log("echoed previous results"); // die(file_get_contents("results.json")); // } // file_put_contents($credentialsPath, json_encode($client->getAccessToken())); // } // return $client; // } // /** // * Expands the home directory alias '~' to the full path. // * @param string $path the path to expand. // * @return string the expanded path. // */ // function expandHomeDirectory($path) // { // $homeDirectory = getenv('HOME'); // if (empty($homeDirectory)) { // $homeDirectory = getenv('HOMEDRIVE') . getenv('HOMEPATH'); // } // return str_replace('~', realpath($homeDirectory), $path); // } // // Get the API client and construct the service object. // $client = getClient(); // $service = new Google_Service_Calendar($client); // date_default_timezone_set("Australia/Perth"); // $calendarId = "54ihu71fo4adsvh6avt8s2lrnk@group.calendar.google.com"; // $optParams = array('timeMin' => date("c", strtotime("now")), 'singleEvents' => true, 'orderBy' => "startTime"); // error_log($calendarId." ".$ref); // $events = $service->events->listEvents($calendarId, $optParams); // //print_r($events); // $dateStart = null; // $dateEnd = null; // $nextDay = null; // $dateArray = array(); // $length = count($events); // //print_r($events->getItems()); // foreach ($events->getItems() as $event) { // $date = new DateTime($event->getStart()->getDate()); // $length = $length - 1; // if($dateStart == null) { // $dateStart = $date; // $nextDay = $date->format("Y-m-d"); // // echo "found start date
"; // } else { // //error_log($date->format("Y-m-d")."!=".$nextDay); // if($date->format("Y-m-d") != $nextDay) { // $lastDay = $nextDay; // $nextDay = date("Y-m-d", strtotime($nextDay.' 00:01 +1 day')); // if(strtotime($date->format("Y-m-d")) > strtotime($nextDay)) { // $dateEnd = $date; // // error_log("found not next day"); // // if($dateStart->format("Y-m-d") != $lastDay) { // array_push($dateArray, ["start" => $dateStart->format("Y-m-d"), "end" => $lastDay, "type" => "CF"]); // // } else { // // array_push($dateArray, ["start" => $dateStart->format("Y-m-d"), "end" => ""]); // // } // $dateStart = $date; // $nextDay = $date->format("Y-m-d"); // } else { // } // } else { // } // if($length == 0) { // // if($dateStart->format("Y-m-d") != $date->format("Y-m-d")) { // array_push($dateArray, ["start" => $dateStart->format("Y-m-d"), "end" => $date->format("Y-m-d"), "type" => "CF"]); // // } else { // // array_push($dateArray, ["start" => $dateStart->format("Y-m-d"), "end" => ""]); // // } // // echo "found end"; // } // } // } // $calendarId = "s1rio4cc0b8ru7nckidvv9or1c@group.calendar.google.com"; // $optParams = array('timeMin' => date("c", strtotime("now")), 'singleEvents' => true, 'orderBy' => "startTime"); // $events = $service->events->listEvents($calendarId, $optParams); // //print_r($events); // $dateStart = null; // $dateEnd = null; // $nextDay = null; // $length = count($events); // foreach ($events->getItems() as $event) { // $date = new DateTime($event->getStart()->getDate()); // $length = $length - 1; // if($dateStart == null) { // $dateStart = $date; // $nextDay = $date->format("Y-m-d"); // // echo "found start date
"; // } else { // //error_log($date->format("Y-m-d")."!=".$nextDay); // error_log(strtotime($date->format("Y-m-d")) .">". strtotime($nextDay)); // if($date->format("Y-m-d") != $nextDay) { // $lastDay = $nextDay; // $nextDay = date("Y-m-d", strtotime($nextDay.' 00:01 +1 day')); // if(strtotime($date->format("Y-m-d")) > strtotime($nextDay)) { // $dateEnd = $date; // // if($dateStart->format("Y-m-d") != $lastDay) { // array_push($dateArray, ["start" => $dateStart->format("Y-m-d"), "end" => $lastDay, "type" => "JB"]); // // } else { // // array_push($dateArray, ["start" => $dateStart->format("Y-m-d"), "end" => ""]); // // } // $dateStart = $date; // $nextDay = $date->format("Y-m-d"); // } else { // } // } else { // } // if($length == 0) { // // if($dateStart->format("Y-m-d") != $date->format("Y-m-d")) { // array_push($dateArray, ["start" => $dateStart->format("Y-m-d"), "end" => $date->format("Y-m-d"), "type" => "JB"]); // // } else { // // array_push($dateArray, ["start" => $dateStart->format("Y-m-d"), "end" => ""]); // // } // // echo "found end"; // } // } // } // $resultPath = expandHomeDirectory('results.json'); // file_put_contents($resultPath, json_encode($dateArray, true)); // echo json_encode($dateArray, true); // //echo $events->items->id; ?>