gpt4 book ai didi

android - 获取可标记的 friend Facebook Android

转载 作者:太空狗 更新时间:2023-10-29 15:02:34 24 4
gpt4 key购买 nike

请注意,这不是一个问题,而只是一个代码 fragment ,您可以随意改进它

使用gson解析Facebook GraphObject

我在做Facebook taggable friends,我解析了GraphObject可能对其他人有帮助。

解析 Taggable friends 函数::需要 user_friends 权限

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 的开发人员凭据登录,你会得到 fried 列表。Sumbit 应用程序用于 facebook 审查,并在得到 facebook 审查后。每个应用程序用户都可以招募他/她的 friend 。

关于android - 获取可标记的 friend Facebook Android,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25132597/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com