Facebook graph api - 某些页面返回空数据集

发布于 2024-09-29 06:43:50 字数 654 浏览 2 评论 0 原文

我正在尝试使用图形 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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

九命猫 2024-10-06 06:43:50

您提到的页面似乎有问题。
我在 Firefox 中尝试 https://graph.facebook.com/Smirnoff 并收到错误消息“false” ”。

我尝试了官方文档(https://developers.facebook.com/docs/reference/api/)中提到的页面,没有发现问题。

页数:
https://graph.facebook.com/cocacola
(可口可乐页面)

{
   "id": "40796308305",
   "name": "Coca-Cola",
   "picture": "http://profile.ak.fbcdn.net/hprofile-ak-snc4/203509_40796308305_256509_s.jpg",
   "link": "https://www.facebook.com/coca-cola",
   "category": "Food/beverages",
   "likes": 29964683,
   "website": "http://www.coca-cola.com",
   "username": "coca-cola",
   "founded": "1886",
   "products": "Coca-Cola is the most popular and biggest-selling soft drink in history, as well as the best-known product in the world.\n\nCreated in Atlanta, Georgia, by Dr. John S. Pemberton, Coca-Cola was first offered as a fountain beverage by mixing Coca-Cola syrup with carbonated water. Coca-Cola was introduced in 1886, patented in 1887, registered as a trademark in 1893 and by 1895 it was being sold in every state and territory in the United States. In 1899, The Coca-Cola Company began franchised bottling operations in the United States.\n\nCoca-Cola might owe its origins to the United States, but its popularity has made it truly universal. Today, you can find Coca-Cola in virtually every part of the world."
}

我想我应该收到一条消息,警告我在尝试 https:// /graph.facebook.com/Smirnoff

好的。让我继续。 (请将粗体文本替换为正确的值。)

  1. 请登录 Facebook 并创建 Facebook 应用程序。

  2. 请访问此链接:
    https://www.facebook.com/dialog/oauth?client_id=YOUR_APP_ID&redirect_uri=URL&scope=user_status,offline_access

  3. 请允许您的 Facebook 应用程序。

  4. 请使用此链接获取访问令牌:
    https://graph.facebook.com/oauth/access_token?client_id=YOUR_APP_ID&client_secret=YOUR_APP_SECRET&grant_type=client_credentials

  5. 请使用以下链接获取应用访问令牌:https://graph.facebook.com/oauth/access_token?client_id=YOUR_APP_ID&client_secret= YOUR_APP_SECRET&grant_type=client_credentials

  6. 请使用刚才获取的access_token访问您的页面。

根据 https://developers.facebook.com/docs/reference/api/ ,人员和页面支持的连接包括:

Friends: https://graph.facebook.com/me/friends?access_token=...
News feed: https://graph.facebook.com/me/home?access_token=...
Profile feed (Wall): https://graph.facebook.com/me/feed?access_token=...
Likes: https://graph.facebook.com/me/likes?access_token=...
Movies: https://graph.facebook.com/me/movies?access_token=...
Music: https://graph.facebook.com/me/music?access_token=...
Books: https://graph.facebook.com/me/books?access_token=...
Notes: https://graph.facebook.com/me/notes?access_token=...
Permissions: https://graph.facebook.com/me/permissions?access_token=...
Photo Tags: https://graph.facebook.com/me/photos?access_token=...
Photo Albums: https://graph.facebook.com/me/albums?access_token=...
Video Tags: https://graph.facebook.com/me/videos?access_token=...
Video Uploads: https://graph.facebook.com/me/videos/uploaded?access_token=...
Events: https://graph.facebook.com/me/events?access_token=...
Groups: https://graph.facebook.com/me/groups?access_token=...
Checkins: https://graph.facebook.com/me/checkins?access_token=...

如果您的页面是音乐页面,请尝试此链接: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.

Pages:
https://graph.facebook.com/cocacola
(Coca-Cola page)

{
   "id": "40796308305",
   "name": "Coca-Cola",
   "picture": "http://profile.ak.fbcdn.net/hprofile-ak-snc4/203509_40796308305_256509_s.jpg",
   "link": "https://www.facebook.com/coca-cola",
   "category": "Food/beverages",
   "likes": 29964683,
   "website": "http://www.coca-cola.com",
   "username": "coca-cola",
   "founded": "1886",
   "products": "Coca-Cola is the most popular and biggest-selling soft drink in history, as well as the best-known product in the world.\n\nCreated in Atlanta, Georgia, by Dr. John S. Pemberton, Coca-Cola was first offered as a fountain beverage by mixing Coca-Cola syrup with carbonated water. Coca-Cola was introduced in 1886, patented in 1887, registered as a trademark in 1893 and by 1895 it was being sold in every state and territory in the United States. In 1899, The Coca-Cola Company began franchised bottling operations in the United States.\n\nCoca-Cola might owe its origins to the United States, but its popularity has made it truly universal. Today, you can find Coca-Cola in virtually every part of the world."
}

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.)

  1. Please log in the Facebook and create a Facebook app.

  2. Please visit this link:
    https://www.facebook.com/dialog/oauth?client_id=YOUR_APP_ID&redirect_uri=URL&scope=user_status,offline_access

  3. Please allow your Facebook app.

  4. 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

  5. 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

  6. 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:

Friends: https://graph.facebook.com/me/friends?access_token=...
News feed: https://graph.facebook.com/me/home?access_token=...
Profile feed (Wall): https://graph.facebook.com/me/feed?access_token=...
Likes: https://graph.facebook.com/me/likes?access_token=...
Movies: https://graph.facebook.com/me/movies?access_token=...
Music: https://graph.facebook.com/me/music?access_token=...
Books: https://graph.facebook.com/me/books?access_token=...
Notes: https://graph.facebook.com/me/notes?access_token=...
Permissions: https://graph.facebook.com/me/permissions?access_token=...
Photo Tags: https://graph.facebook.com/me/photos?access_token=...
Photo Albums: https://graph.facebook.com/me/albums?access_token=...
Video Tags: https://graph.facebook.com/me/videos?access_token=...
Video Uploads: https://graph.facebook.com/me/videos/uploaded?access_token=...
Events: https://graph.facebook.com/me/events?access_token=...
Groups: https://graph.facebook.com/me/groups?access_token=...
Checkins: https://graph.facebook.com/me/checkins?access_token=...

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.

仙女 2024-10-06 06:43:50

该页面需要发布,否则提要中不会显示任何内容

The page needs to be published or nothing is showing up in the feed

君勿笑 2024-10-06 06:43:50

如果您是该页面的管理员,则您尝试访问的大部分内容只能通过 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文