我有一个自定义表单,我正在尝试使用php将字段写入Google日历。
当我提交表单并写入数据库但我也需要写入Google日历。
我调试代码并在insert语句创建事件代码
处停止$createdEvent = $service->events->insert("junkpolice2060@gmail.com", $newEvent);
我对日历ID进行了硬编码,看它是否会继续,但每次停在此处都不会。
请在这里帮忙完整代码
require_once "/var/www/www.junkpolice.com/html/components/com_osservicesbooking/google- api-php-client-master/src/Google/Client.php";
require_once "/var/www/www.junkpolice.com/html/components/com_osservicesbooking/google-api-php-client-master/src/Google/Service.php";
$client_id = '1045785081711- 95hsip42q972lgif5ib744ctrejj9kh3.apps.googleusercontent.com';
$Email_address = 'calendarosbooking@calendarproject1189.iam.gserviceaccount.com';
$key_file_location = '/var/www/www.junkpolice.com/html/components/com_osservicesbooking/Calendar Project-e0174e023f1a.p12';
$gCalenderID = 'junkpolice2060@gmail.com';
try {
$client = new Google_Client();
$client->setApplicationName("CalendarProject");
$client->setClientId($client_id);
$client->setAssertionCredentials(
new Google_Auth_AssertionCredentials(
$Email_address,
array("https://www.googleapis.com/auth/calendar"),
file_get_contents($key_file_location),
'notasecret','http://oauth.net/grant_type/jwt/1.0/bearer',false,false
)
);
}
catch (RuntimeException $e) {
return 'Problem authenticating Google Calendar:'.$e->getMessage();
}
$service = new Google_Service_Calendar($client);
$newEvent = new Google_Service_Calendar_Event();
$newEvent->setSummary($Service);
$newEvent->setLocation($Address);
$newEvent->setDescription($Notes);
$event_start = new Google_Service_Calendar_EventDateTime();
$event_start->setDateTime($startTime);
$newEvent->setStart($event_start);
$event_end = new Google_Service_Calendar_EventDateTime();
$event_end->setDateTime($EndTime);
$newEvent->setEnd($event_end);
$createdEvent = null;
try {
$createdEvent = $service->events- >insert("junkpolice2060@gmail.com", $newEvent);
$createdEvent_id= $createdEvent->getId();
$db->setQuery("Update #__app_sch_order_items set gcalendar_event_id = '$createdEvent_id' where id = '$order_item_id'");
$db->query();
} catch (Google_ServiceException $e) {
//logIt("svgcal_v3,".$e->getMessage());
echo $e->getMessage();
exit;
}