gpt4 book ai didi

android - Facebook android sdk 如何获取给定页面的点赞数

转载 作者:太空宇宙 更新时间:2023-11-03 12:58:07 26 4
gpt4 key购买 nike

我想获取给定页面及其 ID 的点赞数。

这是 graph api request我想用 facebook-android-sdk 翻译。

我不知道怎么做。如果我尝试,我会得到错误:

Bundle params = new Bundle();
params.putString("fields", "likes");
Request request = new Request(session,"104249301622", params, HttpMethod.GET, new Request.Callback() {
@Override
public void onCompleted(Response response) {
JSONObject res = response.getGraphObject().getInnerJSONObject();
System.out.println(res);
}
});

最佳答案

调用方法如下:

Session session = Session.getActiveSession();
Bundle params = new Bundle();
params.putString("id", "104249301622");
params.putString("fields", "likes");
Request request = new Request(session, "search", params, HttpMethod.GET, new Request.Callback() {

@Override
public void onCompleted(Response response) {
try {
JSONObject res = response.getGraphObject().getInnerJSONObject().getJSONArray("data").getJSONObject(0);
numberOfLikes = res.getInt("likes");
} catch (Exception e) {
}
}
});
RequestAsyncTask task = new RequestAsyncTask(request);
task.execute();

请求将翻译成以下graph api request .

关于android - Facebook android sdk 如何获取给定页面的点赞数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16169893/

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