我正在尝试使用服务帐户在Google日历上创建条目.我真的很接近这一点,但最后一行不起作用.500 Internal Service Error当我让这个运行时,我得到了一个.否则,程序运行无错误,无论价值多少.
该Calendar.php文件的内容可以发现在这里.在insert()我试图调用方法开始在该文件上的1455线.
<?php
function calendarize ($title, $desc, $ev_date, $cal_id) {
session_start();
/************************************************
Make an API request authenticated with a service
account.
************************************************/
set_include_path( '../google-api-php-client/src/');
require_once 'Google/Client.php';
require_once 'Google/Service/Calendar.php';
// (not real keys)
$client_id = '843319906820-jarm3f5ctbtjj9b7lp5qdcqal54p1he6.apps.googleusercontent.com';
$service_account_name = '843319906820-jarm3f5ctbtjj7b7lp5qdcqal54p1he6@developer.gserviceaccount.com';
$key_file_location = '../google-api-php-client/calendar-249226a7a27a.p12';
// echo pageHeader("Service Account Access");
if (!strlen($service_account_name) || !strlen($key_file_location))
echo missingServiceAccountDetailsWarning();
$client = new Google_Client();
$client->setApplicationName("xxxx Add Google Calendar Entries");
if (isset($_SESSION['service_token'])) {
$client->setAccessToken($_SESSION['service_token']);
}
$key = file_get_contents($key_file_location); …Run Code Online (Sandbox Code Playgroud) 我有以下代码插入我的特定谷歌日历.它非常成功,但如何让用户可以添加到自己的日历?有人可以帮助我...我的预期结果就像用户可以通过谷歌登录....这意味着用户可以添加到他们自己的谷歌日历.谢谢.
要添加到我的特定日历的代码
require_once './vendor/google/apiclient/src/Google/autoload.php';
$key_file_location = 'Calendar-96992da17e2dda.p12'; // key.p12 to create in the Google API console
$client_id = '6094969424649-compute@developer.gserviceaccount.com';
$service_account_name = 'testsd-440@studied-zephyr-117012.iam.gserviceaccount.com'; // Email Address in the console account
if (strpos($client_id, "gserviceaccount") == false || !strlen($service_account_name) || !strlen($key_file_location)) {
echo "no credentials were set.";
exit;
}
/** We create service access ***/
$client = new Google_Client();
/************************************************
If we have an access token, we can carry on. (Otherwise, we'll get one with the help of an assertion credential.) …Run Code Online (Sandbox Code Playgroud)