2012-01-07 65 views
0

我在使用java編程時遇到了問題。這個java調用谷歌API,它爲我提供GData訪問錯誤代碼@ 5fa01e33在Java中,由於訪問Google API數據而產生

我在查詢某些查詢時遇到了麻煩,導致@ 5fa01e33。這是我的代碼:

package com.thegroovie; 

import java.net.URL; 

import javax.swing.JOptionPane; 

import com.google.gdata.client.DocumentQuery; 
import com.google.gdata.client.docs.DocsService; 
import com.google.gdata.data.docs.DocumentListEntry; 
import com.google.gdata.data.docs.DocumentListFeed; 

public class GDataExample { 
    public static void main(String[] args) { 
    String username = JOptionPane.showInputDialog(null,"Input Username"); 
    String password = JOptionPane.showInputDialog(null,"Input Password"); 

    try{ 
     DocsService service = new DocsService("Document List demo"); 
     service.setProtocolVersion(DocsService.Versions.V3); 
     service.setUserCredentials(username, password); 

     URL documentListFeedUrl = new 
      URL("https://docs.google.com/feeds/default/private/full"); 

     DocumentListFeed feed = service.getFeed(documentListFeedUrl, DocumentListFeed.class); 

     for(DocumentListEntry entry : feed.getEntries()){ 
      System.out.println(entry.getTitle().getPlainText()); 
     } 
     System.out.println("*******************************"); 
     String input_query = JOptionPane.showInputDialog(null,"Search : "); 
     DocumentQuery query = new DocumentQuery(documentListFeedUrl); 
     query.setFullTextQuery(input_query); 
     DocumentListFeed feeds = service.getFeed(query, DocumentListFeed.class); 
     System.out.print(feeds);   
     } 
    catch (Exception ex){ 
      System.err.println("Exception "+ ex.getMessage()); 
     } 
    } 


} 

如何解決這個問題?

謝謝

回答

1

這看起來不像是一個錯誤代碼。而是打印DocumentListFeed對象,該對象的類型沒有覆蓋toString方法。您可以使用文檔中描述的相應訪問器方法訪問Feed的內容。

+0

嗨,謝謝你的回覆。我只是意識到腳本不能使用toString或system.out.print打印 – randytan 2012-01-21 09:40:12