本文介绍了无法得到Facebook的SDK样品和朋友选择器样品只得到android的ID,名称的好友列表中的所有领域的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开发获取登录用户的所有好友​​列表Facebok的样本演示。
我成功运行朋友选择器样品,但getstuck提取的朋友,如电子邮件,名字,姓氏etc.I上午只得到ID,名称。

I am developing facebok sample demo for get all friend list of login user.I am running Friend Picker Sample successfully,But getstuck to extract all the details of friends like email,first_name,last_name etc.I am getting only id,name.

如果任何人有想法,请答复。

If anyone have idea please reply.

下面是我的code: -

Here is mycode:-

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);
            }
        }
    }

在此先感谢...

Thanks in advance...

推荐答案

非常sturggle后,我尝试了一些方法,终于找到解决办法。

After very sturggle i try some methods and finally found solution.

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){

            }
        }
    };

我希望这会帮助别人。谢谢!

I hope this will help others. Thanks!!

这篇关于无法得到Facebook的SDK样品和朋友选择器样品只得到android的ID,名称的好友列表中的所有领域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-23 09:22