我正在使用 SDK 3.0.1 向 android 中的 Facebook api 发出请求,我正在使用 executeAndWait() 运行它,但请求不起作用(在调试中它直接跳转到下一行,甚至不到一毫秒..)并且不调用回调。你能帮我解决一下吗?
我正在请求获取用户的 rsvp_status 中收集的事件列表eventCollection.getAroundMeEventList()
。请求是正确的(我在开放图中尝试过)。
我从来没有进入回调内部,所以即使里面有错误我也不在乎,我想知道如何使这个请求工作。
这是我的代码:
fql 字符串请求:
String rsvpRequest = "{";
for (EventData event : eventCollection.getAroundMeEventList()) {
rsvpRequest += "\""
+ event.event_ID
+ "\":"
+ "\"SELECT rsvp_status FROM event_member where eid = "
+ event.event_ID + " and uid = me()\",";
}
rsvpRequest += "}";
bundle = new Bundle();
bundle.putString("q", rsvpRequest);
脸书请求回调:
Callback callback = new Callback() {
@Override
public void onCompleted(Response response) {
try {
JSONObject jObject = response.getGraphObject()
.getInnerJSONObject();
JSONArray jArray = jObject.getJSONArray("data");
jArray = jArray.getJSONArray(0);
for (int i = 0; i < jArray.length(); i++) {
jObject = jArray.getJSONObject(i);
String ID = jObject.getString("name");
JSONArray jj = jsonObject
.getJSONArray("fql_result_set");
if (jj.length() == 0) {
eventCollection.getAroundMeEventByID(ID).status_attending = "Not Invited";
} else {
jObject = jj.getJSONObject(0);
eventCollection.getAroundMeEventByID(ID).status_attending = jObject
.getString("rsvp_status");
}
}
} catch (Exception e) {
}
}
};
脸书要求:
Request request = new Request(Session.getActiveSession(), "fql", bundle,
HttpMethod.GET, callback);
request.executeAndWait();