1 / 30

Google Data API

Google Data API. 2012/2/22. Google Data API 存取架構. Google Service Gmail 、 Document 、 Account 、 Analytics 、 YouTuBe 、 Maps …. 服務 ( 全部都是雲 ). Google Data API. API. 認證. WEB. Windows. Mobile. 程式. Google Account :認證 Google Calendar :日曆 Google Chart :圖表 Google Document :文件 ( 線上問卷、通訊錄資料蒐集 )

tomas
Télécharger la présentation

Google Data API

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Google Data API 2012/2/22

  2. GoogleData API存取架構 Google Service Gmail、Document、Account、Analytics、YouTuBe、Maps … 服務(全部都是雲) Google Data API API 認證 WEB Windows Mobile 程式

  3. Google Account:認證 • Google Calendar:日曆 • Google Chart:圖表 • Google Document:文件(線上問卷、通訊錄資料蒐集) • Google Search:搜尋引擎 • YouTuBe:影音 • Gmail • Google Maps:網路地圖

  4. 申請Google帳號 • Gmail帳號(rfidctu/rfidctu3600)

  5. 還需要Google_API_Library (I) • http://code.google.com/intl/zh-TW/apis/gdata/ 用戶端程式 Google Data API

  6. 還需要Google_API_Library (II) .NET

  7. 還需要Google_API_Library (III) 下載 然後 安裝

  8. Google_API_Library DEMO • Sample Code • DLL:寫程式需要 • 各位需要做的就是整合變成一個可用的系統 C:\Documents and Settings\Administrator\My Documents\Google Data API SDK\Sources

  9. Google Single Sign on • 所有服務用單一登入窗口

  10. Goolge認證UI • 以Google Document為例

  11. 如何透過程式使用Goolge認證? • Google Data API • 呼叫任何一種服務前都需要通過認證 • 沒有特別(專門)的API • 所以借用呼叫任何一種服務,只要可以被叫用,就表示通過認證

  12. Google Account透過WEB使用方式 • Google Account使用方式:最簡單的方法是使用ClientLogin 這個API • 可以使用瀏覽器先測試 • https://www.google.com/accounts/ClientLogin?accountType=HOSTED_OR_GOOGLE&Email=YourAccount@gmail.com&Passwd=PASSWORD&service=xapi&source=YourCompany-YourApp-Version • Email=YourAccount@gmail.com是你的Google帳號,Passwd=密碼。service是要使用的服務名稱,如果要使用Google Calendar,那就要寫cl • 注意上面的關鍵字是大小寫有別的

  13. ClientLogin之結果 正確 錯誤

  14. 借用Gmail的呼叫服務完成認證.NET Windows Form • 新專案,命名為Google_API TextBox1 TextBox2 Button1 Button2

  15. Free icon & image http://office.microsoft.com/zh-tw/images/ http://www.iconfinder.net/

  16. Button2_Click ' 取消登入 Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click ' 取回使用者回應的資訊 Dim r As Windows.Forms.DialogResult r = MessageBox.Show("確定要取消?", "取消登入", MessageBoxButtons.OKCancel) ' 使用者選擇ok,確定要離開 If r = Windows.Forms.DialogResult.OK Then Application.Exit() End If End Sub

  17. Button1_Click ' 確認登入 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click ' 檢查輸入不為空 If Trim(TextBox1.Text) = "" Or Trim(TextBox2.Text) = "" Then MessageBox.Show("請輸入完整的帳號與密碼!") Exit Sub End If ' 開始Google Account確認 Dim objClient As New System.Net.WebClient Dim response As String ' 宣告Gppgle API呼叫變數 ' 透過服務認證 Try objClient.Credentials = New System.Net.NetworkCredential(TextBox1.Text, TextBox2.Text) response = System.Text.Encoding.UTF8.GetString(objClient.DownloadData("https://mail.google.com/mail/feed/atom")) MessageBox.Show("認證成功") Catch ex As Exception MessageBox.Show("認證失敗") End Try End Sub 可以轉成Web Form?

  18. 重點在 • https://mail.google.com/mail/feed/atom • http://code.google.com/intl/zh-TW/apis/gmail/docs/inbox_feed.html 不同服務對應一個API URI 這裡幾乎都找的到

  19. 可改進問題 • 編號:1 • 問題:判斷目前系統是是可以連上線 • 提示:在Form_Load事件中加入判斷目前是否可以上網,如果不行,則系統不再往下執行…

  20. Google Chart API

  21. API Format • 呼叫方式 • http://chart.apis.google.com/chart?參數 • https://chart.googleapis.com/chart?參數 • 使用方式 • <img src=“呼叫方式”>

  22. 參數 (I) • chs:圖片大小, chs=500x200 • cht:圖片類型,cht=lxy… • http://code.google.com/intl/zh-TW/apis/chart/image/docs/chart_params.html • chd:圖片資料,chd=t:10,20,40,80,90,95,99|0,30,40,50,60,70,80|-1|0,0,0,10,22,35,85 • t:使用數字,第一組是資料所在x座標,每組中間用|分開,每組數列間用-1分隔 • http://code.google.com/intl/zh-TW/apis/chart/image/docs/data_formats.html

  23. 參數 (II) • chco:顏色,每組間用,分隔 • chdl:圖片的legend,chdl=Ponies|Unicorns • chls:線的大小,chls=2,4,1|1 • 寬,長,每個點的間隔,每組參數間用|分開 • chxr:xy軸的label,chxr=0,1,10,1|1,1,5,1 • 配合chxt • y,y最小,y最大,間隔|x,x最小,x最大,間隔 • chxt:圖片要出現的軸線標示,chxt=y,x 大小寫有差別

  24. <img src="http://chart.apis.google.com/chart?chs=440x220&cht=lxy&chco=3072F3,FF0000&chd=t:10,20,40,80,90,95,99|0,30,40,50,60,70,80|-1|0,0,0,10,22,35,85&chdl=Ponies|Unicorns&chls=2,4,1|1&chxr=0,0,100,10|1,0,100,10&chxt=y,x">

  25. Practice • 3組資料 變成

  26. Chart Wizard • http://code.google.com/intl/zh-TW/apis/chart/image/docs/chart_wizard.html

  27. Practice Answer http://chart.apis.google.com/chart   ?chxl=0:|國文|英文|數學&chxr=0,0,95|1,0,100,20   &chxs=0,676767,15,0,l,676767|1,000000,12.5,0,lt,000000   &chxtc=1,3   &chxt=x,y   &chbh=a   &chs=600x400   &cht=bvg   &chco=A2C180,3D7930,FF9900   &chd=t:65,80,25|70,80,90|20,50,80   &chdl=大雄|小叮噹|技安&chtt=成績&chts=FF0000,11.5 中文需要編碼

  28. Call by .NET WebBrowser1.Navigate(Application.StartupPath & "\aa.htm")

  29. Call by .NET Button1

  30. Call by .NET Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim str1 As String = “xxxx”‘xxx=整個api字串前半段 Dim str3 As String = “vvvv”‘vvv=整個api字串後半段 Dim str2 As String str2 = TextBox1.Text & "|" & TextBox2.Text & "|" & TextBox3.Text ‘ 寫入檔案 Dim FileNum As Integer Dim strTemp As String FileNum = FreeFile() FileOpen(FileNum, Application.StartupPath & "\aa.htm", OpenMode.Output) strTemp = str1 & str2 & str3 PrintLine(FileNum, strTemp) FileClose(FileNum) ‘ 顯示圖檔 WebBrowser1.Navigate(Application.StartupPath & "\aa.htm") End Sub

More Related