2012-02-23 1 views
2

Google API에 너무 실망했습니다. 내가 시도 할 때마다, 그것의 단지는 여기 저기에 수조의 항아리를 모은 후에도 작동하지 않는다. 사람이 코드의 다음 조각으로 나를 도울 수 있다면 정말 감사 드리겠습니다 - 내가 클래스 경로에 다음 jar 파일을 추가 한>Google 문서 용 Google gdata api를 실행할 수 없습니다

import java.net.URL; 
import com.google.gdata.client.docs.DocsService; 
import com.google.gdata.data.docs.DocumentListEntry; 
import com.google.gdata.data.docs.DocumentListFeed; 


public class TestGoogleDocs { 

    public static void main(String[] args) { 
     try { 
      System.err.println("== Testing Google Docs =="); 
      DocsService docService = new DocsService("Document list"); 
      docService.setUserCredentials("*****@gmail.com", "******"); 

      URL documentFeedURL = new URL("http://docs.google.com/feeds/documents/private/full"); 

      DocumentListFeed docsFeed = docService.getFeed(documentFeedURL, DocumentListFeed.class); 

      for(DocumentListEntry entry: docsFeed.getEntries()){ 
       System.err.println(entry.getTitle().getPlainText()); 
      } 
     } catch (Exception e) { 
      // TODO Auto-generated catch block 
      e.printStackTrace(); 
     } 
    } 

} 

: 나는 점점 오전

gdata-client-1.0.jar 
gdata-client-meta-1.0.jar 
gdata-core-1.0.jar 
gdata-media-1.0.jar 
gdata-docs-3.0.jar 
gdata-docs-meta-3.0.jar 

activation.jar 
mail.jar 
servlet-api.jar 

guava-r09.jar 

오류는 다음과 같습니다

com.google.gdata.util.ResourceNotFoundException: Not Found 
<HTML> 
<HEAD> 
<TITLE>Not Found</TITLE> 
</HEAD> 
<BODY BGCOLOR="#FFFFFF" TEXT="#000000"> 
<H1>Not Found</H1> 
<H2>Error 404</H2> 
</BODY> 
</HTML> 

    at com.google.gdata.client.http.HttpGDataRequest.handleErrorResponse(HttpGDataRequest.java:591) 
    at com.google.gdata.client.http.GoogleGDataRequest.handleErrorResponse(GoogleGDataRequest.java:563) 
    at com.google.gdata.client.http.HttpGDataRequest.checkResponse(HttpGDataRequest.java:552) 
    at com.google.gdata.client.http.HttpGDataRequest.execute(HttpGDataRequest.java:530) 
    at com.google.gdata.client.http.GoogleGDataRequest.execute(GoogleGDataRequest.java:535) 
    at com.google.gdata.client.Service.getFeed(Service.java:1135) 
    at com.google.gdata.client.Service.getFeed(Service.java:998) 
    at com.google.gdata.client.GoogleService.getFeed(GoogleService.java:631) 
    at com.google.gdata.client.Service.getFeed(Service.java:1017) 
    at com.javainsight.cloud.TestGoogleDocs.main(TestGoogleDocs.java:21) 

답변

3

URL이 문제라고 생각합니다. 자세한 내용은 아래를 참조하십시오.

예제 코드에서 시작하여 gdata/java/sample/docs으로 시작하고 예제에서 DocumentListDocumentList 예외 클래스를 사용하는 것이 좋습니다. 예를합니다 (R09 구아바 JAR와) 나를 위해 일한

import com.google.gdata.data.docs.DocumentListEntry; 
import com.google.gdata.data.docs.DocumentListFeed; 

public class Example { 

static public void main(String[] args) throws Exception { 
    DocumentList docList = new DocumentList("document"); 
    docList.login("********@gmail.com", "********"); 
    DocumentListFeed feed = docList.getDocsListFeed("all"); 
    for (final DocumentListEntry entry : feed.getEntries()) { 
     System.out.println(entry.getTitle().getPlainText()); 
    } 
    } 
} 

:

당신이 경우에 그렇게 그에게 위의 예를 줄일 수 있습니다.

웹 주소는 잘했다 :

이 예제를 추적하는 것은 생성 된 URL이

"https://docs.google.com/feeds/default/private/full" 
+0

감사합니다. 그것은 내 문제를 해결했다. – user381878

0

그래, 나도 그 정도까지. 문제가 Guava 라이브러리와 관련이 있는지 궁금합니다. Guava 11을 사용해 보았지만 현재 gdata 릴리스 (2011 년 9 월) 이후 2011 년 10 월 ImmutableSet.of (Object [] objs) 호출을 제거했습니다.

내 첫 번째 의심은 URL이 될 것입니다 ... 그게 내가 지금하고있는 것입니다.

0

나는 내가 가진 같은 문제를했을 수 있습니다 다른 사람을 위해 하나 개의 메모를 추가 할 것을 제안 ,하지만 guava-11.0.1을 사용하고 있었고, guava-11.0.2를 시도했으며, guava-14를 시도했지만 그 중 아무 것도 작동하지 않았습니다. 이것을 보았을 때 나는 대신 구아바 -r09를 사용했는데 큰 효과가있었습니다.