RestFB Connection返回空结果

时间:2016-08-11 01:14:00

标签: java facebook-graph-api restfb

我将来尝试使用restFB API为多个FB公司网页events since now until获取number of days。不知何故,它什么都没有Facebook Graph API返回结果:

https://developers.facebook.com/tools/explorer/145634995501895/?method=GET&path=AmericanChemicalSociety%2Fevents%3Fsince%3Dnow%26until%3D%2B50%20day&version=v2.7

但是当我尝试在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

问题尚未解决。任何建议都将不胜感激

0 个答案:

没有答案