目前分類:google api 學習 (2)

瀏覽方式: 標題列表 簡短摘要

分享情況:

可以從google doc api上面得到api的使用範例  

https://developers.google.com/google-apps/spreadsheets/?hl=zh-Hant#working_with_list-based_feeds

 但能無法看出相關的get funtion取到的東西的定義為何,

for (ListEntry row : listFeed.getEntries()) {
  // Print the first column's cell value
     s_temp_ret = s_temp_ret +"\n"+ row.getTitle().getPlainText() ;
    //System.out.print(row.getTitle().getPlainText() + "\t");
    // Iterate over the remaining columns, and print each cell value
  for (String tag : row.getCustomElements().getTags()) {
    s_temp_ret =s_temp_ret + "\n-"+ row.getCustomElements().getValue(tag) ;
    // System.out.print(row.getCustomElements().getValue(tag) + "\t");
  }
  //System.out.println();

}

左邊為我自己檔案的內容,右邊為打印出來的測試結果...
20140812_coding  


文章標籤

IRIS 發表在 痞客邦 留言(0) 人氣()

  問題:

嘗試用clinetLogin的方式,取得google doc上的認證權限

SpreadsheetService service =        new SpreadsheetService("ClientLogin");
    service.setUserCredentials(USERNAME, PASSWORD);

 

無奈一直都無法嘗試成功error msg如下:

Exception in thread "main" java.lang.NoClassDefFoundError: com/google/common/collect/Maps
at com.google.gdata.wireformats.AltRegistry.(AltRegistry.java:118)
at com.google.gdata.wireformats.AltRegistry.(AltRegistry.java:100)
at com.google.gdata.client.Service.(Service.java:555)
at Main.main(Main.java:16)
Caused by: java.lang.ClassNotFoundException: com.google.common.collect.Maps
at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
... 4 more

解決方式:

  new SpreadsheetService("ClientLogin");<---傳入的參數:一直以為是這裡的問題!

查了doc 也只是String application name的類別,後來看到某人說這其實不是問題發生點,寫進什麼東西都不是問題的原因(can be anything)

主要的原因是缺了 部份的jar檔案, The problemis a missing .jar file called.

請到google上重新下載

https://code.google.com/p/gdata-java-client/downloads/list 

 

因為開發環境,是用eclipse的library加入 jar檔的

剛開只有注意到lib裡面有jar檔,後來發現deps的資料夾還有二個..掛上之後就好了!!

程式畫面

 

 

 

文章標籤

IRIS 發表在 痞客邦 留言(0) 人氣()