我将来尝试使用restFB
API为多个FB公司网页events
since
now
until
获取number of days
。不知何故,它什么都没有Facebook Graph API返回结果:
但是当我尝试在Java中实现它时它无效:
private Map<String, ArrayList<JsonObject>> fetchEventsForPeriod(Integer daysAhead) {
Map<String, ArrayList<JsonObject>>mapOfEvents = new HashMap<String, ArrayList<JsonObject>>();
if (this.companiesNamesList.size() == 0) {
getCompanies();
}
for (String companyName : this.companiesNamesList) {
ArrayList<JsonObject>companyEventList = new ArrayList<JsonObject>();
Connection<JsonObject> eventListConnection = this.fbClient.fetchConnection(companyName + "/events",
JsonObject.class, Parameter.with("since", "now"), Parameter.with("until", "+ " + daysAhead + " day"));
while (eventListConnection.hasNext()) {
for (List<JsonObject> eventConnectionPage : eventListConnection) {
for (JsonObject event : eventConnectionPage) {
event.put("univNameId", companyName);
String imageURL = formImageURLFromId(event.get("id").toString());
event.put("imageURL", imageURL);
companyEventList.add(event);
}
}
eventListConnection = this.fbClient.fetchConnectionPage(eventListConnection.getNextPageUrl(), JsonObject.class);
}
mapOfEvents.put(companyName, companyEventList);
}
return mapOfEvents;
}
基本上给我空的结果
restFB
已正确初始化并适用于其他更简单的请求:
private final String appAccessToken = "839761616150633|XMK9PSdojx6uCsOmoGccQC7XMTY";
private FacebookClient fbClient;
@SuppressWarnings("deprecation")
public FacebookRestFB() {
this.companiesList = new JsonArray();
this.companiesNamesList = new ArrayList<String>();
try {
this.fbClient = new DefaultFacebookClient(this.appAccessToken, Version.LATEST);
} catch (FacebookException ex) {
ex.printStackTrace(System.err);
}
}
更新#1
问题尚未解决。任何建议都将不胜感激