Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get Facebook Status from Fan Page using API

Tags:

json

facebook

api

I've been trying to get the most recent Facebook Status for a fan page via the API for a while now and can't seem to get what I'm after. I'm really trying to avoid using RSS for it. I can get the full list from the feed via https://graph.facebook.com/174690270761/feed but I want only the last status posted by the page admin, not by anyone else.

Is their an easy way to get it without having to authenticate?

Thanks in advance

edit: https://graph.facebook.com/174690270761/statuses seems to be what I'm looking for but I need an OAuthAccessToken for this but can't see how to without involving the user, as I'm trying to access through my own credentials/application

like image 262
Alex Avatar asked Dec 05 '22 02:12

Alex


1 Answers

Facebook has changed the api and now requires you to provide an access token. You can use Facebooks PHP sdk for that but i found a much quicker way to go:

<?
$appid = '1234567890';
$secret = 'db19c5379c7d5b0c79c7f05dd46da66c';
$pageid = 'Google';

$token = file_get_contents('https://graph.facebook.com/oauth/access_token?grant_type=client_credentials&client_id='.$appid.'&client_secret='.$secret);
$feed = file_get_contents('https://graph.facebook.com/'.$pageid.'/feed&'.$token);

print_r(json_decode($feed));
?>

Update 15/12/12 app access tokens nosist of the id and secret now - use this request:

$feed = file_get_contents('https://graph.facebook.com/Saxity/feed?access_token='.$appid.'|'.$secret);
like image 170
Niksac Avatar answered Dec 23 '22 13:12

Niksac