我看到了关于这个问题与旧版本的SDK的答案的布赫,我似乎无法弄清楚,为什么这是发生在我身上。
如果我使用此代码,它完美:
String QUERY = "select uid, name, pic_square, is_app_user from user where uid in (select uid2 from friend where uid1 = me())";
protected void getFacbookFirends() {
Bundle params = new Bundle();
params.putString("q", QUERY);
final Request req = new Request(getSession(), "/fql", params, HttpMethod.GET, fbCallback);
runOnUiThread(new Runnable() {
@Override
public void run() {
Request.executeBatchAsync(req);
}
});
}
但这是非常难看,所以我试图用这个代替:
Session session = Session.getActiveSession();
if (session == null) {
session = new Session(getActivity());
}
if (session != null && session.isOpened()) {
Request req = Request.newGraphPathRequest(session, "/me/friends?fields=id,name,installed,picture",
new Callback() {
@Override
public void onCompleted(Response response) {
Log.w("FriendsListFragment.Facebook.onComplete", response.toString());
}
});
Request.executeBatchAsync(req);
}
我的理解,这是完全相同的请求,并应运行只是以同样的方式,而是获得我想要的回应,我得到这个Response
对象:
{Response:
responseCode: 400,
graphObject: null,
error: {FacebookServiceErrorException:
httpResponseCode: 400,
facebookErrorCode: 2500,
facebookErrorType: OAuthException,
message: An active access token must be used to query information about the current user.
},
isFromCache:false
}
关于我怎样才能使这项工作很好的任何想法?
编辑:
我试图运行这些代码,并仍然得到了相同的结果:
Request req = new Request(session, "/me/friends?fields=id,name,installed,picture",null, HttpMethod.GET,
new Callback() {
@Override
public void onCompleted(Response response) {
Log.w("FriendsListFragment.Facebook.onComplete", response.toString());
}
});
Request.executeBatchAsync(req);