获取 Facebook Graph api 页面评论 [英] get Facebook Graph api page review
问题描述
我正在尝试从某些地方获得评论/评级,其 fb 页面可能如下所示:
I'm trying to get review/rating from certain place whos fb page can look like this i.e :
https://www.facebook.com/pages/Dell-Rheas-Chicken-Basket/183254918389428
所以这个地方/页面的id是183254918389428
So id of this place/page is 183254918389428
并且您可以获得该地点的详细信息,但无法获得评分/评论:
And you can get the details of this place but not rating/review:
https://graph.facebook.com/183254918389428
我在这个论坛的某个地方发现你可以从这样的页面获得评论:
I found somewhere on this forum that you could get review from page like this :
https://graph.facebook.com/183254918389428/tabs/reviews?access_token=xxx一个>
但我总是得不到数据:
{
"data": [
]
}
所以我不是想获得应用评论/评级,而是针对某个地方.
So I'm not trying to get app review/rating but for certain place.
推荐答案
您需要一个页面访问令牌来获取评论和评级.这是一个关于获取页面访问令牌的非常好的简短教程:获取页面访问令牌.
You'd need a page access token to fetch reviews and ratings. Here is a very good short tutorial on getting a page access token: Obtaining page access token.
https://www.facebook.com/dialog/oauth?client_id=<APP_ID>&redirect_uri=<REDIRECT_URL>&scope=manage_pages&state=<STATE>
这将生成一个CODE
,在:
https://graph.facebook.com/oauth/access_token?client_id=<APP_ID>&client_secret=<APP_SECRET>&code=<CODE>
这将返回一个包含短期用户访问令牌的 json 响应.
This will return you a json response containing short lived user access token.
接下来,使用短期用户令牌获取长期用户令牌:
Next, use the short lived user token to get long lived user token:
https://graph.facebook.com/oauth/access_token?grant_type=fb_exchange_token&client_id=<APP_ID>&client_secret=<APP_SECRET>&fb_exchange_token=<SHORT_LIVED_TOKEN>
这将返回另一个包含长期存在的用户令牌的 json,您现在可以将其交换为页面访问令牌:
This will return another json containing the long lived user token, you can now exchange it for page access token:
https://graph.facebook.com/me/accounts?access_token=<LONG_LIVED_TOKEN>
这将返回一个 json,其中包含与该用户帐户关联的页面的页面访问令牌.使用此页面访问令牌通过将其传递给:
This will return you a json with page access token of the page(s) associated with that user account. Use this page access token to fetch ratings and reviews by passing it to:
https://graph.facebook.com/StoneArmsInc/ratings?access_token=<page_access_token>
您将获得 Facebook 上发布的该页面的所有评分.
And you will get all the ratings posted on facebook for that page.
希望,这对某人有所帮助.:)
Hope, this helps someone. :)
这篇关于获取 Facebook Graph api 页面评论的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!