嗨,我遇到了一个非常小的问题。我正在制作Android应用程序,我已将其与FB集成。我想获得一个Facebook用户喜欢的特定类别的所有页面的列表?
这是我到目前为止编写的代码:
new GraphRequest(
AccessToken.getCurrentAccessToken(),
user_id+"/likes/",
null,
HttpMethod.GET,
new GraphRequest.Callback() {
@Override
public void onCompleted(GraphResponse graphResponse) {
Log.d("check",graphResponse.toString());
}
}).executeAsync();
这将返回所有喜欢页面的JSON对象。每个FB页面都有一个名为category的字段。例如,类别是服装。现在我怎么才能得到用户喜欢的服装页面?谢谢
答案 0 :(得分:1)
您无法使用Graph API进行过滤,至少现在不行。获得所有参赛作品后,您必须自己完成。
答案 1 :(得分:0)
我使用以下代码来获取用户仅在音乐类别
中喜欢的页面请求:
GraphRequest request = GraphRequest.newGraphPathRequest(
accessToken,
"/me/music",
new GraphRequest.Callback() {
@Override
public void onCompleted(GraphResponse response) {
// Insert your code here
}
});
Bundle parameters = new Bundle();
parameters.putString("fields", "link");
request.setParameters(parameters);
request.executeAsync();
回应:
{
"data": [
{
"link": "https://www.facebook.com/Vh1Supersonic/",
"id": "557785804313645"
},
{
"link": "https://www.facebook.com/onedirectionmusic/",
"id": "121930497861753"
},
{
"link": "https://www.facebook.com/seanpaul/",
"id": "10161539667"
},
{
"link": "https://www.facebook.com/officialflo/",
"id": "53856904324"
},
{
"link": "https://www.facebook.com/seankingston/",
"id": "5128508749"
},
{
"link": "https://www.facebook.com/DavidGuetta/",
"id": "7619396355"
},
{
"link": "https://www.facebook.com/TaylorSwift/",
"id": "19614945368"
},
{
"link": "https://www.facebook.com/pitbull/",
"id": "95051637400"
},
{
"link": "https://www.facebook.com/michaeljackson/",
"id": "19691681472"
},
{
"link": "https://www.facebook.com/usher/",
"id": "6564142497"
},
{
"link": "https://www.facebook.com/AKON/",
"id": "16929140023"
},
{
"link": "https://www.facebook.com/linkinpark/",
"id": "8210451787"
}
],
"paging": {
"cursors": {
"before": "NTUDK3Nzg1ODA0MzEzNjQ1",
"after": "ODIxMDQ1MOM2Tc4NwZDZD"
}
}
}