Feed on
Posts
Comments
Email訂閱

This post is under 軟體開發

旅聯網行事曆

為了在旅聯網增加行事曆的功能,研究如何納入Google Calender API。找尋一些網路上的中文範例都指向使用Zend Framework就可以順利完成Calendar讀取新增修改刪除等基本動作。譬如照著這位作者的Google Calendar API系列文章,當可以開發出整合Google Calendar API的應用。

實際嘗試的結果發現幾個關卡:

    1. Google Calendar API已經升級為3.0,而此範例使用的仍是2.0的版本。得先到Google 帳號取啟用用Google Calendar API 3的服務。
    2. 在local本機上按照範例可以實作出來。但移植到遠端伺服器之後卻出現授權的問題。因為Google Calendar API 3已經使用OAuth的使用者認證方式,而舊版的方式是輸入使用者的帳號密碼。
    3. 懶得研究google calendar 3的API,仍想要使用現在的Zend範例。來到Zend Famework網站的使用者認證說明文件,看到可以改使用OAuth 的session token方式登入:
      $client = Zend_Gdata_AuthSub::getHttpClient($accessToken);
      2014/11/18之後不能再使用 zend 呼叫 google calendar API。改用這一篇做法:http://stackoverflow.com/questions/27011264/authentification-zend-gdata-403-forbidden/27034888 (150821 更新)
    4. 但如何取得accessToken?在這篇國外的文章中敘述了使用OAuth的Google Calender API 範例: How to embed a Google Calendar into a web page and use it to accept online bookings/appointments from other online users
    5. 在step 4要注意的事項很多,包括 Part 2: OAuth2 and Configuring Your ‘Application’ With Google。此處取得Client ID的介面稍微有點變動。而且必須先為這個project設定名稱,否則未來取得授權時會出現錯誤。
    6. google透過code取得token的方式跟facebook類似。但以code取得的是fresh_token(永不失效),需要再從fresh_token再取得asscessToken。
    7. 有時在step5取得fresh_code時,會有問題。可能跟scope有關。可參考step4的連結文章中的留言多試幾次。

 

 

2 則回應 to “Google Calendar API v3(140214) – 150821 更新”

  1. 陳 志鴻表示:

    旅聯網的行事曆似乎不能用

    http://www.waytogo.cc/calendar.php

    張貼行程之後沒反應

回覆 冬烘先生