When I go to this url in by browser, it shows me the json feed i expect:
https://www.facebook.com/feeds/page.php?format=json&id=237173582992285
When in PHP I do a
<?php
print_r(file_get_contents('https://www.facebook.com/feeds/page.php?format=json&id=237173582992285'));
?>
I get an html page saying my browser is not supported by facebook and that I should upgrade. How do I make the file_get_contents return the json feed I'm expecting?
Additional Notes I also tried from bash wget https://www.facebook.com/feeds/page.php?format=json&id=237173582992285
and the file I downloaded also has html content saying browser not supported.
Try this, it works for me
To get the public posts of a page you should be using its corresponding connection which is the
feed
connection with any validaccess_token
.So to get the public feeds of the page you mentioned, you use
/237173582992285/feed
. Further more, you can choose to get only the data you need, for example/237173582992285?fields=feed.fields(message,type,status_type)
would result in something like:Read more about the Page end-point here.
You should use the Facebook API instead. The Graph API Explorer should help get you started as well as the documentation on the Pages API.
The feeds are designed for use by RSS readers and not for consumption by scripts. You could in theory get around this by changing the
User-Agent
header, but this is against Facebook's terms of service