1

长话短说:我正在尝试通过一个名为 Abugadro 的 Android 应用在 Google Code 上发表评论和创建问题。

我在这里遵循了一段非常相似的代码: Google Spreadsheet API update \ edit with protocol

尝试在 API 上发表评论时,我收到了各种错误,例如 403 和 501,具体取决于我使用的标头。

无论如何,代码会说话,所以这是我的作品:

HttpPost postRequest = new HttpPost("http://code.google.com/feeds/issues/p/"+projName+"/issues/"+issueId+"/comments/full");

postRequest.addHeader("Content-Type","application/atom+xml;charset=UTF-8");
postRequest.setHeader("Authorization", "GoogleLogin auth=" + auth);
postRequest.addHeader("User-Agent", "abugadro-v"+getResources().getString(R.string.version));
postRequest.addHeader("Accept-Encoding","gzip");
postRequest.addHeader("GData-Version", "1.0");
//postRequest.addHeader("If-Match", "*");//Not entirely sure if I should use this or not

HttpEntity se = new StringEntity(xml,"UTF-8"); //Contains the comment info              
postRequest.setEntity(se);

IssueTrackerAPI 对我应该使用哪种标题来正确发布非常模糊。 http://code.google.com/p/support/wiki/IssueTrackerAPI#Modifying_an_issue_or_creating_issue_comments

PS我知道有一个gdata-java-client但是没有理智的方法可以在android上使用该api而不拖动〜2mb的jar。

我非常感谢您的帮助,这个问题一直让我发疯,无法理解。再次感谢。

4

1 回答 1

1

Google API 的最佳 Android 库是google-api-java-client,它支持 Android。gdata-java-client不支持安卓。

google-api-java-client 支持 Issue Tracker API,但还没有示例。请索取样品。同时,您可以查看为 Android 编写的其他一些示例,例如picasa-atom-android-samplecalendar-v2-atom-android-sample

于 2010-09-24T02:00:45.040 回答