我正在使用SDK 3.0.1向android API中的Facebook api发出请求,我正在使用executeAndWait()运行它但请求不起作用(在调试中它直接跳转到下一行,甚至不是毫秒..)并且不调用回调。你能帮我解决一下吗?
我正在请求获取用户的eventCollection.getAroundMeEventList()
中收集的事件列表的rsvp_status。请求是正确的(我在开放图中尝试过)。
我从来没有进入回调,所以即使在里面出现错误,我也不关心它,我想知道如何使这个请求有效。
这是我的代码:
fql string request:
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);
facebook Request.Callback:
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) {
}
}
};
facebook 请求:
Request request = new Request(Session.getActiveSession(), "fql", bundle,
HttpMethod.GET, callback);
request.executeAndWait();
答案 0 :(得分:0)
调用此方法的正确方法如下:
Request request = new Request(Session.getActiveSession(), "fql", bundle,
HttpMethod.GET);
Response response = request.executeAnWait();
希望这有帮助