我正在创建一个Android应用程序。该应用程序具有使用Graph API检索Facebook帖子的功能。
我的问题
我的问题是,收到的JSON缺少以下字段:
full_picture
字段仅包含指向一个图片的链接。其他图片的链接在哪里?我使用/me/posts
来获取帖子。
为什么我无法获得上述详细信息?
采取的步骤
我搜索了Stackoverflow,但答案只提到了如何获取单个提交的图像和回复(通过使用注释ID),但没有参考如何使用从"/me/posts"
收到的JSON来获取它。 (所以,这不是重复!!!!)
我的查询
"/me/posts"
的JSON而不是{{1}请求每一条评论? 我的代码
编码执行图形查询
/comment
JSON
login_button.setReadPermissions(Arrays.asList(
"public_profile", "email", "user_birthday", "user_friends","user_posts", "user_status")); // Setting permissions
Bundle params = new Bundle();
params.putString("fields", "message,created_time,id,full_picture,status_type,source,comments.summary(true),likes.summary(true)");
params.putString("limit", "100");
new GraphRequest( loginResult.getAccessToken(), "/me/posts", params, HttpMethod.GET,
new GraphRequest.Callback() {
public void onCompleted(GraphResponse response) {
/* handle the result */
try {
EditText postsText = (EditText) findViewById(R.id.postText);
String res = response.toString();
res = res.replaceAll("\\{Response:\\s*\\w*\\W*\\s*[0-9]*\\W*\\w*:", "");
res = res.replaceAll("\\,\\s*error:\\s*null\\W*\\s*","");
postsText.setText(res);
writeToFile(res,"response");
}
catch (Exception e) {
e.printStackTrace();
}
}
}
).executeAsync();
}
@Override
public void onCancel() {
txtstatus.setText("Login canceled");
}
@Override
public void onError(FacebookException error) {
txtstatus.setText("Login failed"+error.getMessage());
}
});
答案 0 :(得分:0)
好吧,关于“反应列表”,这仅适用于Page拥有者(从2018年Febraury开始)。
阅读Graph API文档: https://developers.facebook.com/docs/graph-api/reference/v2.12/post
“对于页面上的帖子:
任何有效的访问令牌都可以读取公共页面上的帖子,但响应不会包含用户信息。 页面访问令牌可以读取该页面发布或发布的所有帖子,响应将包括用户信息。“