我在春天为facebook graph api找到了restFB客户端库,我必须得到页面评论和审阅者的名字和头像。我在https://restfb.com/javadoc-3/com/restfb/types/Page.html中搜索这个,但找不到任何方法
有没有可能通过restFB库获得页面评论、审阅者的姓名和头像url?
发布于 2020-07-06 20:41:43
获得收视率就有点棘手了。
让我们假设您有一个带有正确页面访问令牌的FacebookClient。然后,您可以像这样开始呼叫:
Connection<OpenGraphRating> ogRatingConn =
facebookClient.fetchConnection("me/ratings",
OpenGraphRating.class,
Parameter.with("fields", "reviewer,review_text,has_rating,recommendation_type"));然后,您可以遍历该连接。检查OpenGraphRating对象,了解您可以使用的方法。
我建议另外检查open_graph_story字段,因为这样可以获得更多信息。然后请求如下所示(为了便于使用,我在这里删除了其他OpenGraphRating字段)。
Connection<OpenGraphRating> ogRatingConn =
facebookClient.fetchConnection("me/ratings",
OpenGraphRating.class,
Parameter.with("fields", "open_graph_story{id,from,message,publish_time,type,data{recommendation_type,rating,language,review_text},comments.limit(0).summary(1).filter(stream)}"));在本例中,您可以使用作为OpenGraphRating对象一部分的getOpenGraphStory方法访问字段。
发布于 2020-07-06 19:57:55
使用facebook官方api
https://developers.facebook.com/docs/graph-api/reference/page/ratings/
/* PHP SDK v5.0.0 */
/* make the API call */
try {
// Returns a `Facebook\FacebookResponse` object
$response = $fb->get(
'/{page-id}/ratings',
'{access-token}'
);
} catch(Facebook\Exceptions\FacebookResponseException $e) {
echo 'Graph returned an error: ' . $e->getMessage();
exit;
} catch(Facebook\Exceptions\FacebookSDKException $e) {
echo 'Facebook SDK returned an error: ' . $e->getMessage();
exit;
}
$graphNode = $response->getGraphNode();
/* handle the result */https://stackoverflow.com/questions/62754612
复制相似问题