【发布时间】:2015-02-13 11:01:59
【问题描述】:
如何使用 abdera 将状态更新发布到 ibm 连接?
我正在尝试使用闲置代码将状态发布到 ibm 连接。
public class PostStatusUpdate {
public void postStatus(String username, String password, String feedURL) throws MalformedURLException, URISyntaxException {
try{
Abdera abdera = new Abdera();
AbderaClient client = new AbderaClient(abdera);
AbderaClient.registerTrustManager();
RequestOptions options = client.getDefaultRequestOptions();
URL url = new URL(feedURL);
String realm = url.getProtocol() + "://" + url.getHost();
client.usePreemptiveAuthentication(true);
try {
client.addCredentials(realm, null, null, new UsernamePasswordCredentials(username, password));
} catch (URISyntaxException e) {
e.printStackTrace();
}
Parser parser = abdera.getParser();
String urlText = "https://greenhouse.lotus.com/connections/opensocial/basic/rest/ublog/@me/@all";
String message = "Hai This is Tes Content Fron Nithin!";
Entry status = abdera.newEntry();
status.addCategory("http://www.ibm.com/xmlns/prod/sn/type", "entry", null);
status.addCategory("http://www.ibm.com/xmlns/prod/sn/message-type", "status", null);
message = StringEscapeUtils.escapeHtml4(message);
status.setContent(message);
ClientResponse response = client.put(urlText, status);
if (response.getType() == ResponseType.SUCCESS) {
System.out.println("I have posted status");
} else {
System.out.println("I failed");
}
}catch(Exception e){
System.out.println("Exception E -->"+e);
}
}
}
请帮忙。
【问题讨论】:
-
微博只基于json,不基于atom。 www-10.lotus.com/ldd/appdevwiki.nsf/…
-
但是如何使用这个 API 更新消息?...@PaulBastide
-
使用前面评论中链接的 REST API
-
您能否提供一个如何使用 REST API 的示例。我提到的上述代码是否需要他们进行任何修改
-
老兄,这里有一个例子:IBM Connections wiki。 PS:示例使用 XML,而不是 json。关键是——正如 Paul Bastide 所说——你需要使用 REST API。
标签: java ibm-connections apache-abdera