iT邦幫忙

0

Google Calendar api 疑問

版上有人用過Google calendar API 嗎?
小弟目前有幾個問題
1.使用https://developers.google.com/calendar/quickstart/php 是只能連結自己設定的行事曆嗎?
2.我想要讓客戶登入我的網站(Google登入),然後製作可以幫該客戶加入是件到他的行事曆,目前權限都有設定了。卡在https://developers.google.com/calendar/v3/reference/calendarList/get 這裡,小弟不知道要怎麼使用這部分的code

看更多先前的討論...收起先前的討論...
ccutmis iT邦高手 2 級 ‧ 2019-10-04 09:56:05 檢舉
https://stackoverflow.com/questions/56242345/allow-my-user-to-add-meeting-in-my-calendar-with-google-calendar-api-with-php-wi

不確定這是不是你要的 而且我也沒試過 不過就文章標題描述的是跟你想作的蠻類似的可以參考看看...
loukei iT邦新手 5 級 ‧ 2019-10-04 10:26:14 檢舉
照google doc的內容看起來,get方法是單純按照"calendarId"這個變數取得帳戶使用者的CalendarList。
如果calendarId的值是primary則回傳主日曆(primary calendar)
每個API右邊都有try it可以直接嘗試API效果,可以自己試試看。

這裡有[PHP範例](https://developers.google.com/calendar/quickstart/php)

我不確定你要用CalendarList做什麼,但是加入事件應該是從insert方法之類去找吧?

clientID的部份,引用doc的內容
> calendarId is the calendar identifier and can either be the email address of the calendar on which to create the event or a special keyword 'primary' which will use the primary calendar of the logged in user.

就是說clientID的值可以填入任意email,或者用primary表示登入者本身
就是用來指向事件要加入的目標
豬豬人 iT邦新手 4 級 ‧ 2019-10-04 10:31:33 檢舉
因為想說先試試看get 大概了解要怎麼應用在往下做
loukei iT邦新手 5 級 ‧ 2019-10-04 11:33:41 檢舉
我沒摸過PHP,就不提供外行人意見了
官方範例
[Create Events](https://developers.google.com/calendar/create-events)

你要做的最主要就是這行
```
$calendarId = 'primary';
$event = $service->events->insert($calendarId, $event);
printf('Event created: %s\n', $event->htmlLink);
```
看懂event如何構造,知道google回傳的訊息是不是有問題
應該就可以達成你要的目標了

另外ㄧ件事是restful api是利用http封包為主體建立請求/回應
所以只要明白PHP api只是方便你建立請求的過程
完全可以利用PHP自己寫http封包發送達成一樣操作
就不會奇怪它為何沒有提供完整程式碼
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友回答

立即登入回答