如何使用Java使用正确的实体构建http post请求而不使用任何库?
我应该如何构建实体以实现此发布请求?
POST https://picasaweb.google.com/data/feed/api/user/userID/albumid/albumID/photoid/photoID
<entry xmlns='http://www.w3.org/2005/Atom'>
<content>great photo!</content>
<category scheme="http://schemas.google.com/g/2005#kind"
term="http://schemas.google.com/photos/2007#comment"/>
</entry>
来自于:
http://code.google.com/intl/zh-TW/apis/picasaweb/docs/2.0/developers_guide_protocol.html#AddComments
有人可以提供示例或任何提示吗?
非常感谢。
更新:
我在这里添加了我的代码:
List<Header> headers = new ArrayList<Header>();
headers.add(new BasicHeader("GData-Version", "2"));
headers.add(new BasicHeader("Authorization", "GoogleLogin auth=" + mAuthToken));
EntityTemplate entity = new EntityTemplate(new ContentProducer() {
public void writeTo(OutputStream ostream) throws IOException {
Writer writer = new OutputStreamWriter(ostream, "UTF-8");
writer.write("rn");
writer.write("<entry xmlns='http://www.w3.org/2005/Atom'>");
writer.write("<content>" + comment + "</content>");
writer.write("<category scheme="http://schemas.google.com/g/2005#kind"rn");
writer.write("term="http://schemas.google.com/photos/2007#comment"/>");
writer.write("</entry>rn");
writer.flush();
}
});
仍然没有运气。任何的想法?
没有找到相关结果
已邀请:
3 个回复
蜂佬渺
藐刚
参考以下网址。 http://code.google.com/intl/ja/apis/picasaweb/docs/2.0/developers_guide_java.html http://code.google.com/p/gdata-java-client/downloads(GDataAPI下载) http://code.google.com/p/guava-libraries/(Guava-libraries)
号拳藐孔妇