我正在尝试创建一个从页面ID列表中返回页面名称和页面照片的方法,请求似乎返回null,问题的解决方案将作为更好方法的建议而受到赞赏为了我想要实现的目标。
public void getPages(){
for(int f=0;f<Json.PI;f++){
final int j = f;
final Request photo = new Request(
null,
"/" + PhotoId,
null,
HttpMethod.GET,
new Request.Callback() {
public void onCompleted(Response response) {
GraphObject graphObject = response.getGraphObject();
JSONObject jsonObject = graphObject.getInnerJSONObject();
try {
PageInfo[j][1] = (String) jsonObject.get("picture");
Log.i("PICTURE", PageInfo[j][1]);
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
);
final Request photos = new Request(
MainFragment.activeSession,
"/"+likes[f]+"/photos/uploaded",
null,
HttpMethod.GET,
new Request.Callback() {
public void onCompleted(Response response) {
GraphObject graphObject = response.getGraphObject();
JSONObject jsonObject = graphObject.getInnerJSONObject();
try {
JSONArray array = jsonObject.getJSONArray("data");
JSONObject object = (JSONObject) array.get(0);
Log.i("PHOTOID", (String) object.get("id"));
PhotoId = (String) object.get("id");
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Log.i("PNAME", String.valueOf(response));
}
}
);
Request PageID = new Request(MainFragment.activeSession, "/"+likes[f], null, HttpMethod.GET, new Request.Callback() {
public void onCompleted(Response response) {
Log.i("RESP", String.valueOf(response));
}
}
);
Requests.add(PageID);
Requests.add(photos);
Log.i("TAG", "ADDED");
}
Requests.executeAsync();
来自facebook的回复如下
{Response: responseCode: 400, graphObject: null, error: {HttpStatus: -1, errorCode: -1, errorType: null, errorMessage: Unexpected number of results}, isFromCache:false}
为什么它会返回null?
答案 0 :(得分:1)
为什么不使用FQL查询:
select page_id, name, pic from page where page_id in ({your_comma_separated_list_of_page_ids})
这将只需要一个请求。使用
GET /fql?q={your_urlencoded_query}&access_token={your_access_token}
端点。