我正在尝试使用图形 API 从 Facebook 获取数据。
我提出的请求如下所示:http://graph.facebook.com//
,它返回有关页面的基本数据。如果我确实请求:http://graph.facebook.com/,我会得到一个包含此页面提要数据的 json。
有些页面需要身份验证才能访问它们 - 例如 Smirnoff 页面 (http://graph.facebook.com/Smirnoff
) 和其他一些“酒精”页面(我认为)。因此,我为我正在使用的应用程序生成了 access_token
,赋予它访问我的帐户的权限。现在我可以获取 Smirnoff
的基本数据,但是每当我尝试访问较低级别的数据(例如 feed
或 >posts
),我在 json 中得到一个空数组:
{
"data": [
]
}
有什么方法可以从 API 获取此数据吗?或者是被页面所有者屏蔽了?或者也许我的授权应用程序需要额外的权限?
I'm trying to fetch data from Facebook, using the graph API.
The request I make looks like this: http://graph.facebook.com/<page_name>/
, it returns basic data about the page. If I do request for: http://graph.facebook.com/<page_name/feed/
, I get a json with data from this page's feed.
There are some pages that require authentication to access them - for example the Smirnoff page (http://graph.facebook.com/Smirnoff
) and some others "alcohol" pages (I think). So I generated access_token
for the application I'm using, giving it the permisssions to access my account. Now I'm able to fetch the basic data for Smirnoff
, but whenever I try to access lower-level data (like feed
or posts
), I get an empty array in json:
{
"data": [
]
}
Is there any way to get to this data from the API? Or is it blocked by page owner? Or maybe my authorized application needs extra permissions?
发布评论
评论(3)
您提到的页面似乎有问题。
我在 Firefox 中尝试 https://graph.facebook.com/Smirnoff 并收到错误消息“false” ”。
我尝试了官方文档(https://developers.facebook.com/docs/reference/api/)中提到的页面,没有发现问题。
我想我应该收到一条消息,警告我在尝试 https:// /graph.facebook.com/Smirnoff。
好的。让我继续。 (请将粗体文本替换为正确的值。)
请登录 Facebook 并创建 Facebook 应用程序。
请访问此链接:
https://www.facebook.com/dialog/oauth?client_id=YOUR_APP_ID&redirect_uri=URL&scope=user_status,offline_access
请允许您的 Facebook 应用程序。
请使用此链接获取访问令牌:
https://graph.facebook.com/oauth/access_token?client_id=YOUR_APP_ID&client_secret=YOUR_APP_SECRET&grant_type=client_credentials
请使用以下链接获取应用访问令牌:https://graph.facebook.com/oauth/access_token?client_id=YOUR_APP_ID&client_secret= YOUR_APP_SECRET&grant_type=client_credentials
请使用刚才获取的access_token访问您的页面。
根据 https://developers.facebook.com/docs/reference/api/ ,人员和页面支持的连接包括:
如果您的页面是音乐页面,请尝试此链接:https://graph.facebook.com/me/music?access_token=ACCESS_TOKEN
请告诉我我的方法是否有效。谢谢。
Something seems wrong with the page you mentioned.
I tried https://graph.facebook.com/Smirnoff in my Firefox and got the error message "false".
I tried the page mentioned in the official document (https://developers.facebook.com/docs/reference/api/) and found no problem.
I think I should get the message warning me that I should use an access token when trying https://graph.facebook.com/Smirnoff.
OK. Let me continue. (Please replace the text in bold with the proper value.)
Please log in the Facebook and create a Facebook app.
Please visit this link:
https://www.facebook.com/dialog/oauth?client_id=YOUR_APP_ID&redirect_uri=URL&scope=user_status,offline_access
Please allow your Facebook app.
Please get the access token by using this link:
https://graph.facebook.com/oauth/access_token?client_id=YOUR_APP_ID&client_secret=YOUR_APP_SECRET&grant_type=client_credentials
Please get the app access token by using this link: https://graph.facebook.com/oauth/access_token?client_id=YOUR_APP_ID&client_secret=YOUR_APP_SECRET&grant_type=client_credentials
Please visit your page with the access_token got just now.
According to https://developers.facebook.com/docs/reference/api/, The connections supported for people and pages include:
If you page is a music page, please try this link: https://graph.facebook.com/me/music?access_token=ACCESS_TOKEN
Please let me know whether my method works. Thanks.
该页面需要发布,否则提要中不会显示任何内容
The page needs to be published or nothing is showing up in the feed
如果您是该页面的管理员,则您尝试访问的大部分内容只能通过 API 访问。当您收到空数组时,几乎总是这样:所提供的访问令牌无权访问您所请求的内容。如果访问令牌无效,那么 API 实际上会抛出错误。
Much of the content you are trying to access is only available through the API if you are an administrator of that page. When you receive an empty array as a result it is almost always the case that the access token provided doesn't have permission to access what you are requesting. If the access token was invalid, then the API would actually throw an error.