我正在尝试从公共页面获取事件,我尝试了很多方法:
方法一:
Connection<Event> myFeed = fbClient.fetchConnection(pageID+"/events", Event.class);
List<Event> abc = myFeed.getData();
for (List<Event> myFeedConnectionPage : myFeed) {
for (Event post : myFeedConnectionPage) {
System.out.println("ABC " + post.getName());
}
}
方法二:
Connection <Event> myEventDescription = fbClient.fetchConnection (pageID+"/events", Event.class, Parameter.with ("Fields", "name, description"));
for (Event e : myEventDescription.getData()) {
System.out.println("ABC1 " + e.toString());
}
方法三:
Event event = fbClient.fetchObject(pageID+"/events", Event.class);
System.out.println(event.toString());
方法四:
Connection<JsonObject> eventListConnection = fbClient.fetchConnection("164788810237714/events",
JsonObject.class);
while (eventListConnection.hasNext()) {
for (List<JsonObject> eventConnectionPage : eventListConnection) {
for (JsonObject test : eventConnectionPage) {
System.out.println("ABC3 " + test.toString());
}
}
}
似乎没有任何效果,无论是null还是空,或者没有通过sys。但是当我在facebook图表中运行它时。我可以得到我需要的数据:
164788810237714/events?fields=id,name
{
"data": [
{
"id": "594948540530494",
"name": "BSN Putrajaya Night Marathon 2013"
},
{
"id": "656503507700225",
"name": "Pelancaran School Bank"
},
有什么想法吗?
答案 0 :(得分:0)
通过添加版本修复:
new DefaultFacebookClient(accessToken.getAccessToken(), Version.VERSION_2_6);
似乎版本2.7无法提取事件的数据,但2.6可以工作。