获得可标记的朋友Facebook Android



如何改进这段代码?

使用gson解析Facebook graphject

我在Facebook上工作可标记的朋友,我已经解析了GraphObject可能对别人有帮助。

Parse Taggable friends function:: user_friends permission required

public void getTaggableFriends(){
    Session activeSession = Session.getActiveSession();
    if(activeSession.getState().isOpened()){
    new Request(
            activeSession,
            "/me/taggable_friends",
            null,
            HttpMethod.GET,
            new Request.Callback() {
                public void onCompleted(Response response) {
                    
                    GraphObject graphObject = response.getGraphObject();
                    if (graphObject != null) {
                        JSONObject jsonObject = graphObject.getInnerJSONObject();
                        String taggableFriendsJson = jsonObject.toString();
                        Gson gson = new Gson();
                        TaggableFriendsWrapper taggableFriendsWrapper= gson.fromJson(taggableFriendsJson, TaggableFriendsWrapper.class);
                    }else {
                        // do something
                    }
                    //response.get
                    
                }
            }
        ).executeAsync();
    }
}

TaggableFriendsWrapper.java

   public class TaggableFriendsWrapper {
    
    private ArrayList<TaggableFriends> data;
    private Paging paging;
    
    public ArrayList<TaggableFriends> getData() {
        return data;
    }
    public void setData(ArrayList<TaggableFriends> data) {
        this.data = data;
    }
    
    public Paging getPaging() {
        return paging;
    }
    public void setPaging(Paging paging) {
        this.paging = paging;
    }
    public class Paging {
        
        private Cursors cursors;
        public Cursors getCursors() {
            return cursors;
        }
        public void setCursors(Cursors cursors) {
            this.cursors = cursors;
        }
    }
    
    public class Cursors {
        private String after;
        private String before;
        
        public String getAfter() {
            return after;
        }
        public void setAfter(String after) {
            this.after = after;
        }
        public String getBefore() {
            return before;
        }
        public void setBefore(String before) {
            this.before = before;
        }
        
    }
    
}

TaggableFriends.java

    public class TaggableFriends {
    
    private String id;
    private String name;
    private Picture picture;
    
    public String getId() {
        return id;
    }
    public void setId(String id) {
        this.id = id;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    
    public Picture getPicture() {
        return picture;
    }
    public void setPicture(Picture picture) {
        this.picture = picture;
    }
    public class Picture {
        
        private Data data;
        public Data getData() {
            return data;
        }
        public void setData(Data data) {
            this.data = data;
        }
    }
    
    public class Data {
        
        private String url;
        private boolean is_sillhouette;
        
        public String getUrl() {
            return url;
        }
        public void setUrl(String url) {
            this.url = url;
        }
        public boolean isIs_sillhouette() {
            return is_sillhouette;
        }
        public void setIs_sillhouette(boolean is_sillhouette) {
            this.is_sillhouette = is_sillhouette;
        }
    }
    
        
}

Facebook可标记好友样本回复

{
    "data": [
        {
            "picture": {
                "data": {
                    "url": "dummy_url.jpg",
                    "is_silhouette": false
                }
            },
            "id": "AaJfT2z9C1_tj00pdLMtmCSpsX70e_Hreb4xrY94jzK_lJOK5H9H16jjtZPnUPeyFWSszXZtY5mtA-FBkYaPJ24AV9X-8SXGc7_OxXjVBoCA",
            "name": "John Smith"
        },
        {
            "picture": {
                "data": {
                    "url": "dummy_url.jpg",
                    "is_silhouette": false
                }
            },
            "id": "AaK6xdBkzhkSOtr4C1NOI6TiqU4AUr6wzAFVh6KOivnmYqmOHCY_ThHqiC8Pw-2mOElasdLCCDgMvsmSN-dUaGmXpeEKl6Rtq_HMiZw9hAVMmdpOw",
            "name": "Tom Jerry"
        },
        {
            "picture": {
                "data": {
                    "url": "dummy_url.jpg",
                    "is_silhouette": false
                }
            },
            "id": "AaLlnBhsYq4uXpCob_xz8iEToLXf8au_10cBhNVqpJSoJAriDUOefS_w_cc9pg2wPkyasdo5sha75EwhmwJ1HjlVhtkC8e8mSi57F8v1Eo2U_GM6w",
            "name": "Tabour Michael"
        },
        {
            "picture": {
                "data": {
                    "url": "dummy_url.jpg",
                    "is_silhouette": false
                }
            },
            "id": "AaL3P25QKM7pcdRGasRhq3YwK4ijlKutMOErBdUiAqW9Nw2hXqMfk42gBb-T15szRIG38aUyZgaJwgfQ4mI_3vDCQbm0GkSPA7ZmEfVi3My72k4w",
            "name": "Robert Paul"
        }
    ],
    "paging": {
        "cursors": {
            "after": "QWFMS2ZzRnV1eFNyZzloRW1JNElCcFVUckFJY0hTVll6QXk1QUlObHYtbkJVRW9fdmZ4NTdrV1ZLa3RYUEIzLWw4M1RSTVFsZ0xnOGtLVGRycTVab3lnZnlhaEVQS05RcXpxdXFBWHk3U3VpY3c=",
            "before": "QWFLckx0Z29jNExEUnFSTHF1NXVpNWZrTVVEb1dnajNNTHBRdmlHbjB6MUZpYXZWaXo0cUtqenRFOVFtaTdJSVZBaV84NkpfMGZDZlQ3X0RPT0dwSmhyRFU4M1JtMUgtZU9PMHpSdzFSSXVoQnc="
        }
    }
}

我得到了答案,上面使用的api总是返回朋友的信息给开发者,尝试使用facebook的开发者证书登录,您将获得油炸列表。Sumbit的应用程序为facebook的评论,并得到了facebook的评论后。每个应用程序用户都可以招募他/她的朋友

相关内容

  • 没有找到相关文章

最新更新