我试图从社区活动中的某个部分获取所有活动。
首先,我循环遍历所有活动:
ActivityList allActivities = service.getAllActivities();
for(Activity activity : allActivities) {
if("community_activity".equals(activity.getEntryType())) {
...
对于每个社区活动,我遍历ActivityNodes:
ActivityNodeList activityNodesFromActivity = service.getActivityNodes(activity.getActivityId());
for (ActivityNode activityNode : activityNodesFromActivity) {
...
到目前为止一切顺利。但是因为有些活动可以是Sections,所以我想再次循环它们以让他们的孩子'#39;活动。
ActivityNodeList activityNodesFromSection = service.getActivityNodes(activityNode.getActivityId());
现在我为这些请求收到403错误:
<error xmlns="http://www.ibm.com/xmlns/prod/sn">
<code/>
<message>
Identifier: LCFED1E22083D5412BB4A4E5ABB1D26B10 Request denied
</message>
<displaymessage/>
<errortype/>
<trace>
java.lang.Exception: Identifier: LCFED1E22083D5412BB4A4E5ABB1D26B10 Request denied
</trace>
</error>
因此SBT丢失了OAuth令牌,我必须再次登录SmartCloud并进行大访问。
是否有其他/更好的方式从社区活动的某个部分获取活动?
btw:我使用的是SBT的第二个版本:1.0.0.20140125-1133
答案 0 :(得分:1)
尝试这种方法......
您可以扩展基础“extends ActivityService”
/**
* Method to get Activity nodes from Section
*
* @param includeSelf
* @param nodeUuid
* @param sectionId
* @return ActivityNodeList
* @throws ActivityServiceException
*/
public ActivityNodeList getActivityNodesInSection(String nodeUuid, String sectionId boolean includeSelf) throws ActivityServiceException {
private String sectionUri = "/activities/service/atom2/descendants";
if (null == activityId ){
throw new ActivityServiceException(null, "Null activityId");
}
/**
* Includes section node, if it's true
*/
String include = "no";
if(includeSelf){
include = "yes";
}
try {
Map<String, String> params = new HashMap<String, String>();
params.put("nodeUuid", activityId);
params.put("includeSelf", include);
params.put("section", sectionId);
return (ActivityNodeList) getEntities(sectionUri, params, new ActivityNodeFeedHandler(this));
} catch (Exception e) {
throw new ActivityServiceException(e);
}
}
然后你调用的函数 - 在你的情况下,nodeUuid和sectionid应该是相同的。