Hi
google Calendar event can't insert
my code
function create_calendar_event($token , $description, $leaveDate ,
$toLeaveDate ){
try{
$title = 'Leave today';
$start_time = '00:00'; $end_time = '23:59';
$timezone = 'Asia/Kolkata';
$start = array(
"dateTime" => $leaveDate . "T" . $start_time . ":00",
"timeZone" => $timezone
);
$end = array(
"dateTime" => $toLeaveDate . "T" . $end_time . ":00",
"timeZone" => $timezone
);
$headerarray = array(
'Content-type: application/json',
'Authorization: Bearer ' . $token->access_token,
'X-JavaScript-User-Agent: Google APIs Explorer'
);
$post_data = array(
"start" => $start,
"end" => $end,
"summary" => $title,
"description" => $description
);
$post_data = json_encode($post_data);
$calendar_id = 'primary';
$url = 'https://www.googleapis.com/calendar/v3/calendars/' . $calendar_id .
'/events';
$result = $this->curlRequest($url, $headerarray, $post_data);
return $result;
}catch(Exception $e){
// Exception
}
}
function curlRequest($url,$headerarray,$post_data, $curl_call = true){
try{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HTTPGET, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headerarray);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$server_output = curl_exec($ch);
$info = curl_getinfo($ch);
$header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
$headers = substr($server_output, 0, $header_size);
$response = substr($server_output, $header_size);
$data = array();
if($info['http_code'] == 200) {
$data['headers'] = $headers;
$data['response'] = json_decode($response);
$data['status'] = 'SUCCESS';
} else {
if($info['http_code'] == 404) {
$data['response'] = 'Not Found';
$data['status'] = 'ERROR';
} else {
$data['response'] = json_decode($response);
$data['status'] = 'ERROR';
}
$data['headers'] = $headers;
}
curl_close($ch);
return $data;
} catch (Exception $e) {
// Exception
}
}
--
You received this message because you are subscribed to the Google Groups
"Google App Engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/google-appengine.
To view this discussion on the web visit
https://groups.google.com/d/msgid/google-appengine/078b0f53-e002-42de-b5f0-8164addb6d7b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.