Android的入门Facebook好友列表以及SDK 3.0 [英] Android Getting Facebook friend list with SDK 3.0

查看:200
本文介绍了Android的入门Facebook好友列表以及SDK 3.0的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想了一整天得到使用Facebook的SDK 3.0我所有的Facebook好友列表
我不想用FriendPickerFragment,因为我不想要显示选择器,我要创造我自己的朋友列表(显示名称和图像)。

I'm trying all day to get all my Facebook friend list using Facebook SDK 3.0 I don't want to use the FriendPickerFragment, since i don't want to display a picker, i want to create my own list of friends (displaying the name and image).

根据这个帖子的 Facebook好友列表只有当这是可能返回空朋友批准您的应用程序,但即使我想这与我的妻子的帐户和我的,我还没有能够得到好友列表。

According to this post Facebook friends list returns empty this is possible only if a friend approves your app, but even when i tried this with my wife's account and mine, i'm still not able to get the friend list.

任何帮助将是非常美联社preciated,我已经花这个这么多时间和达到死锁。

any help will be highly appreciated, I've spend so much time on this and reach a dead lock.

谢谢!

推荐答案

precondition:

1.在Facebook上创建一个应用程序。

2.加入Android应用的哈希code到Facebook的应用程序。

Precondition:
1. Create an app on facebook.
2. Add hash code of android app into facebook app.

Android应用:

获得许可(上谁创造了FB应用的FB账号)

Android app:
get permission (on your fb account who created fb app)

authButton.setReadPermissions(Arrays.asList("basic_info, user_friends"));

authButton是com.facebook.widget.LoginButton(可以参考示例应用程序,以了解如何登录按钮作品)

authButton is com.facebook.widget.LoginButton (you can refer sample apps to find out how the login button works)

方法获取好友列表:

   Request r = new Request(session, "/me/friends", null,HttpMethod.GET, new Request.Callback() {
                        @Override
                        public void onCompleted(Response response) {
                            try {
                                GraphObject graphObj = response.getGraphObject();
                                if(graphObj != null){
                                    ArrayList<FBFriend> friendArrayList = new ArrayList<FBFriend>();
                                    JSONObject jsonObj = graphObj.getInnerJSONObject();
                                    JSONArray array = jsonObj.getJSONArray(DATA_NODE);
                                    for(int i = 0; i < array.length(); i++){
                                        JSONObject Jobj = (JSONObject)array.get(i);
                                        String id = Jobj.getString(FBFriend.ID_NOTE);
                                        String name = Jobj.getString(FBFriend.NAME_NOTE);
                                        FBFriend f = new FBFriend(id, name);
                                        friendArrayList.add(f);
                                    }
                                }
                            }
                        }
                    });
r.executeAsync()

这篇关于Android的入门Facebook好友列表以及SDK 3.0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆