无法获取Facebook SDK示例中的朋友列表的所有字段和Android中的朋友选择器示例中的ID仅获取名称

哈格迪什

我正在开发facebok示例演示,以获取登录用户的所有朋友列表。我正在成功运行“朋友选择器”示例,但是搞砸了要提取朋友的所有详细信息,例如电子邮件,名字,姓氏等。我仅获得id,名字。

如果有人有主意,请回复。

这是我的代码:-

public void getFriends(Properties properties, final OnFriendsRequestListener onFriendsRequestListener)
    {
        // if we are logged in
        if (isLogin())
        {
            // move these params to method call parameters
            Session session = getOpenSession();
            Bundle bundle = null;
            if (properties != null)
            {
                bundle = properties.getBundle();

            }
            Request request = new Request(session, "me/friends", bundle, HttpMethod.GET, new Request.Callback()
            {
                @Override
                public void onCompleted(Response response)
                {
                    List<GraphUser> graphUsers = typedListFromResponse(response, GraphUser.class);

                    FacebookRequestError error = response.getError();
                    if (error != null)
                    {
                        // log
                        logError("failed to get friends", error.getException());

                        // callback with 'exception'
                        if (onFriendsRequestListener != null)
                        {
                            onFriendsRequestListener.onException(error.getException());
                        }
                    }
                    else
                    {
                        // callback with 'complete'
                        if (onFriendsRequestListener != null)
                        {
                            List<Profile> friends = new ArrayList<Profile>(graphUsers.size());
                            for (GraphUser graphUser: graphUsers)
                            {

                                friends.add(Profile.create(graphUser));
                            }
                            onFriendsRequestListener.onComplete(friends);
                        }
                    }

                }
            });

            RequestAsyncTask task = new RequestAsyncTask(request);
            task.execute();

            // callback with 'thinking'
            if (onFriendsRequestListener != null)
            {
                onFriendsRequestListener.onThinking();
            }
        }
        else
        {
            String reason = Errors.getError(ErrorMsg.LOGIN);
            logError(reason, null);

            // callback with 'fail' due to not being loged
            if (onFriendsRequestListener != null)
            {
                onFriendsRequestListener.onFail(reason);
            }
        }
    }

提前致谢...

哈格迪什

经过非常努力之后,我尝试了一些方法,终于找到了解决方案。

public void getFriendsList() {
        Bundle bundle=new Bundle();
        bundle.putString("fields","id,name,first_name,last_name,email,picture,gender,birthday,work");
        mAsyncRunner.request("me/friends",bundle,friendsRequsetListener,null); 

    }


RequestListener friendsRequsetListener =new RequestListener() {

        @Override
        public void onMalformedURLException(MalformedURLException e, Object state) {
            // TODO Auto-generated method stub

        }

        @Override
        public void onIOException(IOException e, Object state) {
            // TODO Auto-generated method stub

        }

        @Override
        public void onFileNotFoundException(FileNotFoundException e, Object state) {
            // TODO Auto-generated method stub

        }

        @Override
        public void onFacebookError(FacebookError e, Object state) {
            // TODO Auto-generated method stub

        }

        @Override
        public void onComplete(String response, Object state) {
            // TODO Auto-generated method stub
            String json = response;
            try {
                Log.e("Response","========>"+json);

                    }
            catch(Exception e){

            }
        }
    };

我希望这会帮助其他人。谢谢!!

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

Related 相关文章

热门标签

归档