第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

無法使用 google calendar api php 創(chuàng)建事件

無法使用 google calendar api php 創(chuàng)建事件

PHP
冉冉說 2023-04-28 16:35:10
我已經(jīng)按照所有說明、php quickstart 和 events.insert 頁面進行了操作;但是當我運行它時,會彈出同意書,我單擊允許,然后除了同意書重置之外沒有任何反應(yīng)。如果我將重定向 URL 更改為另一個頁面,則它不再重置同意書,但仍然沒有任何反應(yīng)。$client = new Google_Client();$client->setAuthConfig('redacted');$client->addScope("https://www.googleapis.com/auth/calendar");$client->addScope("https://www.googleapis.com/auth/calendar.events");$client->setRedirectUri('http://redacted/GoogleClientWorksCalendar.php');//this is the current file$client->setAccessType('offline');$client->setIncludeGrantedScopes(true);$client->setPrompt('consent');$auth_url = $client->createAuthUrl();header('Location: ' . filter_var($auth_url, FILTER_SANITIZE_URL));$service = new Google_Service_Calendar($client);$event = new Google_Service_Calendar_Event(array(  'summary' => 'test',  'location' => 'somewhere',  'description' => 'test description',  'start' => array(    'dateTime' => '2020-09-03T09:00:00+02:00',  ),  'end' => array(    'dateTime' => '2020-09-03T17:00:00+02:00',  ),));$calendarId = 'redacted';$results = $service->events->insert($calendarId, $event);
查看完整描述

1 回答

?
慕沐林林

TA貢獻2016條經(jīng)驗 獲得超9個贊

我已經(jīng)解決了我的問題。問題是我忘記了所需的谷歌 Oauth2.0 代碼的一部分,這意味著我從未收到訪問令牌。下面的代碼片段功能齊全。希望對大家有幫助,謝謝大家的回答。


$client = new Google_Client();


$client->setAuthConfig('redacted');


$client->addScope("https://www.googleapis.com/auth/calendar");


$client->addScope("https://www.googleapis.com/auth/calendar.events");


$client->setRedirectUri('http://redacted/GoogleClientWorksCalendar.php');//this is the current file


$client->setAccessType('offline');


$client->setIncludeGrantedScopes(true);


$client->setPrompt('consent');


$auth_url = $client->createAuthUrl();

header('Location: ' . filter_var($auth_url, FILTER_SANITIZE_URL));


$client->authenticate($_GET['code']);

$access_token = $client->getAccessToken();

$client->setAccessToken($access_token);


$service = new Google_Service_Calendar($client);


$event = new Google_Service_Calendar_Event(array(

  'summary' => 'test',

  'location' => 'somewhere',

  'description' => 'test description',

  'start' => array(

    'dateTime' => '2020-09-03T09:00:00+02:00',


  ),

  'end' => array(

    'dateTime' => '2020-09-03T17:00:00+02:00',


  ),




));


$calendarId = 'redacted';

$results = $service->events->insert($calendarId, $event);


查看完整回答
反對 回復(fù) 2023-04-28
  • 1 回答
  • 0 關(guān)注
  • 148 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號