我正在使用Facebook SDK在墙上发布消息.
现在我需要获取Facebook好友列表.任何人都可以帮我吗?
- 编辑 -
try {
Facebook mFacebook = new Facebook(Constants.FB_APP_ID);
AsyncFacebookRunner mAsyncRunner = new AsyncFacebookRunner(mFacebook);
Bundle bundle = new Bundle();
bundle.putString("fields", "birthday");
mFacebook.request("me/friends", bundle);
} catch(Exception e){
Log.e(Constants.LOGTAG, " " + CLASSTAG + " Exception = "+e.getMessage());
}
Run Code Online (Sandbox Code Playgroud)
当我执行我的时候activity,我没有看到任何东西,但是LogCat有一个调试消息,如:
06-04 17:43:13.863: DEBUG/Facebook-Util(409): GET URL: https://graph.facebook.com/me/friends?format=json&fields=birthday
Run Code Online (Sandbox Code Playgroud)
当我尝试直接从浏览器访问此URL时,我收到以下错误响应:
{
error: {
type: "OAuthException"
message: "An active access token must be used to query information about the current user."
}
}
Run Code Online (Sandbox Code Playgroud) 我一直在寻找在developers.facebook网站寻找一种方式来使用新的SDK和发送FQL查询,但似乎一切都已经改变和文档都在谈论各种其他的方式来请求,me或者friends,但没有具体的信息,和那些使用我的应用程序的朋友一样?
所以我写下了一个不错的FQL查询
select uid, name, pic_square, is_app_user from user where uid in (select uid2 from friend where uid1 = me())
Run Code Online (Sandbox Code Playgroud)
而现在,我所要做的就是运行它.
由于回复朋友列表的唯一请求似乎是好的Request.executeMyFriendsRequestAsync,Request.newMyFriendsRequest我认为他们是我的朋友,但两者都不允许微调FQL查询.
如何发送查询并获取朋友列表或至少一个JSONArray?
Hackbook - FQL查询教程使用旧版本的SDK,我不知道该怎么做.
更新:
我添加了这些代码行,以为它会让我创建这个查询:
public void onCreate(Bundle savedInstanceState) {
// SOME CODE
this.openSession();
}
protected void onSessionStateChange(SessionState state, Exception exception) {
if (state.isOpened()) {
Session activeSession = getSession().getActiveSession();
facebook.setAccessToken(activeSession.getAccessToken());
facebook.setAccessExpires(activeSession.getExpirationDate().getTime());
Request req = Request.newMyFriendsRequest(activeSession, new GraphUserListCallback() {
@Override
public void onCompleted(List<GraphUser> users, Response response) …Run Code Online (Sandbox Code Playgroud)