FB好友名单谁已经认证的同一个应用程序 [英] FB friends list who have already authenticated the same application

查看:158
本文介绍了FB好友名单谁已经认证的同一个应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我与Facebook图形API的工作:

I am working with Facebook graph api:

我需要得到谁已经AUTHENTICATED我的申请好友列表中。

I need to get the list of friends who have already AUTHENTICATED MY APPLICATION.

第一个问题:
这可能吗?

First question: IS THIS POSSIBLE?

,如果是请指导我我应该从哪里开始寻找它。

and if yes please guide me where should I start searching for it.

我已经经历了这么走了类似的问题,并没有适合我的情况。

I have already gone through SO for similar question and none suits in my case.

请帮帮忙!
谢谢你。

Please help! Thank you.

推荐答案

Facebook的API提供了一个布尔字段,可以帮助你过滤用户的好友与你的应用程序安装。您需要为用户的好友列表的请求,并设置所需的字段包括安装布尔值。下面code段可能会帮助你。

Facebook API provides a boolean field that can help you filter the User's friends with your application Installed. You need to Make a request for User's Friends List and set the required fields to include the "installed" boolean. The following code snippet may help you out.

private void requestMyAppFacebookFriendsWithAppInstalled(Session session) {

            Request friendsRequest = createRequest(session);
            friendsRequest.setCallback(new Request.Callback() 
                {
            @Override
            public void onCompleted(Response response) 
            {
            //SetUpList
            List<GraphUser> friends = getResults(response);
            GraphUser user;
            friendsList=new ArrayList<ACT_friendsListPicker.FB_FriendsListStructure>();
            boolean installed = false;
             if(friends!=null)
             {
              for(int count=0;count<friends.size();count++)
              {
                user = friends.get(count);
                if(user.getProperty("installed") != null)
                {
            installed = (Boolean) user.getProperty("installed");
            Log.i("frndsPickerAppInstalled? YES ","user: "+user.getInnerJSONObject());
                }
             }}}});



    private Request createRequest(Session session) {
            Request request = Request.newGraphPathRequest(session, "me/friends", null);

            Set<String> fields = new HashSet<String>();
            String[] requiredFields = new String[] { "id", "name", "picture","hometown",
            "installed" };
            fields.addAll(Arrays.asList(requiredFields));

            Bundle parameters = request.getParameters();
            parameters.putString("fields", TextUtils.join(",", fields));
            request.setParameters(parameters);

            return request;
        }



private class FB_FriendsListStructure
    {
        String Name,ID,ImageUrl;
        boolean selected;
    }


private List<GraphUser> getResults(Response response) throws NullPointerException
    {
        try{
            GraphMultiResult multiResult = response
                    .getGraphObjectAs(GraphMultiResult.class);
            GraphObjectList<GraphObject> data = multiResult.getData();
            return data.castToListOf(GraphUser.class);
        }
        catch(NullPointerException e)
        {
           return null;
               //at times the flow enters this catch block. I could not figure out the reason for this.
        }
    }

这篇关于FB好友名单谁已经认证的同一个应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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