Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Facebook graph api - some pages return empty data set

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?

like image 497
kender Avatar asked Nov 14 '22 06:11

kender


1 Answers

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.

like image 60
Box Avatar answered Dec 30 '22 10:12

Box