使用 IBM Connections 加入社区 API
Join a Community using the IBM Connections API
所以我在尝试以编程方式加入社区时遇到了一些问题 (http://www-10.lotus.com/ldd/lcwiki.nsf/xpAPIViewer.xsp?lookupName=IBM+Connections+5.0+API+Documentation#action=openDocument&res_title=Creating_a_request_to_join_a_community_ic50&content=apicontent)
这是我的请求代码:
private boolean verifyCommunityMembership(String username, String password) throws HttpException, IOException {
HttpClient client = new HttpClient();
UsernamePasswordCredentials credentials = new UsernamePasswordCredentials(username, password);
AuthScope authscope = new AuthScope("w3-connections.ibm.com", AuthScope.ANY_PORT, AuthScope.ANY_REALM);
client.getState().setCredentials(authscope, credentials);
PostMethod postMethod = new PostMethod("https://w3-connections.ibm.com/communities/service/atom/community/requestsToJoin?communityUuid=758e69a5-47e6-4843-abb7-db1b9ef194f9");
RequestEntity requestEntity = generateReplyEntity("CommunityJoinTemplate.xml", null, null, null, username);
postMethod.setRequestEntity(requestEntity);
int statusCode = client.executeMethod(postMethod);
if(statusCode == 200 || statusCode == 409){
return true;
} else {
return false;
}
这是我的 XML 文件:
<?xml version="1.0" encoding="UTF-8"?>
<entry xmlns:snx="ibm.com/xmlns/prod/sn" xmlns="w3.org/2005/Atom">
<contributor> <email>#EMAIL#</email></contributor>
</entry>
'generateRequestEntity' 函数只是将#EMAIL# 替换为用户的电子邮件地址。
但是,我收到了 500 错误。任何帮助将不胜感激。
您应该将入口节点从
更改为
<entry xmlns:snx="ibm.com/xmlns/prod/sn" xmlns="w3.org/2005/Atom">
到
<entry xmlns:thr="http://purl.org/syndication/thread/1.0" xmlns="http://www.w3.org/2005/Atom" xmlns:snx="http://www.ibm.com/xmlns/prod/sn">
我用过
<?xml version="1.0" encoding="UTF-8"?>
<entry xmlns:thr="http://purl.org/syndication/thread/1.0" xmlns="http://www.w3.org/2005/Atom" xmlns:snx="http://www.ibm.com/xmlns/prod/sn">
<title type="text">ignored</title>
<content type="html">reason to join</content>
<contributor> <email>ajones4@janet.iris.com</email></contributor>
</entry>
所以我在尝试以编程方式加入社区时遇到了一些问题 (http://www-10.lotus.com/ldd/lcwiki.nsf/xpAPIViewer.xsp?lookupName=IBM+Connections+5.0+API+Documentation#action=openDocument&res_title=Creating_a_request_to_join_a_community_ic50&content=apicontent)
这是我的请求代码:
private boolean verifyCommunityMembership(String username, String password) throws HttpException, IOException {
HttpClient client = new HttpClient();
UsernamePasswordCredentials credentials = new UsernamePasswordCredentials(username, password);
AuthScope authscope = new AuthScope("w3-connections.ibm.com", AuthScope.ANY_PORT, AuthScope.ANY_REALM);
client.getState().setCredentials(authscope, credentials);
PostMethod postMethod = new PostMethod("https://w3-connections.ibm.com/communities/service/atom/community/requestsToJoin?communityUuid=758e69a5-47e6-4843-abb7-db1b9ef194f9");
RequestEntity requestEntity = generateReplyEntity("CommunityJoinTemplate.xml", null, null, null, username);
postMethod.setRequestEntity(requestEntity);
int statusCode = client.executeMethod(postMethod);
if(statusCode == 200 || statusCode == 409){
return true;
} else {
return false;
}
这是我的 XML 文件:
<?xml version="1.0" encoding="UTF-8"?>
<entry xmlns:snx="ibm.com/xmlns/prod/sn" xmlns="w3.org/2005/Atom">
<contributor> <email>#EMAIL#</email></contributor>
</entry>
'generateRequestEntity' 函数只是将#EMAIL# 替换为用户的电子邮件地址。
但是,我收到了 500 错误。任何帮助将不胜感激。
您应该将入口节点从
更改为<entry xmlns:snx="ibm.com/xmlns/prod/sn" xmlns="w3.org/2005/Atom">
到
<entry xmlns:thr="http://purl.org/syndication/thread/1.0" xmlns="http://www.w3.org/2005/Atom" xmlns:snx="http://www.ibm.com/xmlns/prod/sn">
我用过
<?xml version="1.0" encoding="UTF-8"?>
<entry xmlns:thr="http://purl.org/syndication/thread/1.0" xmlns="http://www.w3.org/2005/Atom" xmlns:snx="http://www.ibm.com/xmlns/prod/sn">
<title type="text">ignored</title>
<content type="html">reason to join</content>
<contributor> <email>ajones4@janet.iris.com</email></contributor>
</entry>