谷歌日历与本地主机上的html静态表单集成


Google calendar integration with html static form on localhost

我正在尝试使用服务帐户在Google日历上创建条目。我真的很接近这一点。

当我让它运行时,我收到以下错误:

警告:file_get_contents() 期望参数 1 是有效路径,字符串在第 54 行的 D:''wamp''www''calendar-test''google-api-php-client''src''Google''Signer''P12.php 中给出

致命错误:未捕获的异常"Google_Auth_Exception",消息"无法解析 p12 文件。这是一个 .p12 文件吗?密码正确吗?OpenSSL 错误:错误:0906D06C:PEM 例程:PEM_read_bio:无起始行' 在 D:''wamp''www''calendar-test''google-api-php-client''src''Google''Signer''P12.php 在第 56 行

Google_Auth_Exception:无法分析 p12 文件。这是一个 .p12 文件吗?密码正确吗?OpenSSL 错误:错误:0906D06C:PEM 例程:PEM_read_bio:第 56 行的 D:''wamp''www''calendar-test''google-api-php-client''src''Google''Signer''P12.php 中没有起始行

    require_once "google-api-php-client/src/Google/autoload.php";
    require_once "google-api-php-client/src/Google/Client.php";
    require_once "google-api-php-client/src/Google/Service/Calendar.php";
    //obviously, insert your own credentials from the service account in the Google Developer's console
    $client_id = '1014261369752...........';
    $service_account_name = 'agentbranding@appspot.gserviceaccount.com';
    $key_file_location = 'google-api-php-client/agentbranding-..........p12';
    //echo $key_file_location;
    if (!strlen($service_account_name) || !strlen($key_file_location))
        echo missingServiceAccountDetailsWarning();
    $client = new Google_Client();
    $client->setApplicationName("Agent Branding Appointment");
    if (isset($_SESSION['service_token'])) {
        $client->setAccessToken($_SESSION['service_token']);
    }
$key = file_get_contents($key_file_location);
    $client->setClientId($client_id);
    $client->setAssertionCredentials(new Google_Auth_AssertionCredentials(
    $service_account_name, 'https://www.google.com/calendar/feeds/........6mp0df4@group.calendar.google.com/private/full/',
    $key)
    );
    $client->setClientId($client_id);
    $calendarService = new Google_Service_Calendar($client);
    $calendarList = $calendarService->calendarList;
    //Set the Event data
    $event = new Google_Service_Calendar_Event();
    $event->setSummary('Today Big Event');
    $event->setDescription('Big Event Dedcription');
    $start = new Google_Service_Calendar_EventDateTime();
    $start->setDateTime('2016-02-17T17:00:00-07:00');
    $event->setStart($start);
    $end = new Google_Service_Calendar_EventDateTime();
    $end->setDateTime('2016-02-18T17:00:00-07:00');
    $event->setEnd($end);
    $createdEvent = $calendarService->events->insert('$cal_id', $event);
    echo $createdEvent->getId();

如果是 google-api-php-client/agentbranding-..........p12是真实的文件名(我的意思是点),我建议

$key_file_location = dirname(__FILE__).'/google-api-php-client/agentbranding-..........p12';