Facebook图形API - 一些页面返回空数据集

时间:2010-10-27 11:57:49

标签: facebook facebook-graph-api

我正在尝试使用图表API从Facebook获取数据。

我发出的请求如下所示:http://graph.facebook.com/<page_name>/,它返回有关页面的基本数据。如果我确实请求:http://graph.facebook.com/<page_name/feed/,我会收到一封json,其中包含此页面Feed中的数据。

有些页面需要身份验证才能访问它们 - 例如Smirnoff页面(http://graph.facebook.com/Smirnoff)和其他一些“酒精”页面(我认为)。所以我为我正在使用的应用程序生成了access_token,为其提供了访问我帐户的权限。现在,我可以获取Smirnoff基本数据,但每当我尝试访问较低级别的数据(例如feedposts)时,我在json中获取一个空数组:

{
   "data": [

   ]
}

有没有办法从API获取此数据?或者被页面所有者阻止了吗?或许我的授权应用程序需要额外的权限?

4 个答案:

答案 0 :(得分:2)

您提到的页面似乎有些问题。 我在我的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 = <强>网址&安培;范围= 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 &amp; client_secret = YOUR_APP_SECRET &amp; grant_type = client_credentials

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

  7. 根据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

    请告诉我方法是否有效。感谢。

答案 1 :(得分:2)

页面需要发布或Feed中没有显示任何内容

答案 2 :(得分:0)

如果您是该网页的管理员,那么您尝试访问的大部分内容只能通过API获得。当您收到一个空数组时,几乎总是这样,所提供的访问令牌无权访问您请求的内容。如果访问令牌无效,那么API实际上会抛出错误。

答案 3 :(得分:-3)

我特别在可口可乐上得到了错误。当我在GET中发送我的access_token时,它可以提取他们相册的照片。如果我不认为它只是一个空集。