tags:

views:

74

answers:

2

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

+1  A: 

I don't think there's a good way to do this. You can process the JSON pretty easily though from the looks of it. You can limit the number of results by using the since query parameter. For instance:

https://graph.facebook.com/174690270761/feed?since=last%20Monday

You can also use limit on that, but I don't think that filters by user. If the administrator is the only one allowed to post, then you may be able to get away with using limit=1.

SB
Thanks for the help. Managed to get access to just the statuses from https://graph.facebook.com/174690270761/statuses but now need an OAuthAccessToken despite it not being secured data. Source (http://www.slideshare.net/busse/facebook-open-graph-protocol-and-graph-api-no-va-cc-2010-1)
Alex
Yea - I was trying to provide a solution to your initial question of not needing a token :) The APIs become a lot more flexible once you have a token.
SB
yeah I thought with publicly open data it might be possible to not use a token. What I don't get is how to authenticate using PHP without involving the user at all, as I can't see any examples that do that :/
Alex
I should elaborate, I mean authenticate as in I only need to get the Status of a 'fan/business page', not a page belonging to a user. I can't see how to pass static credentials to get access to the Status data though, all the examples I see only use Facebook Logins etc for a website visitor to use, not hardcoded server-side :(
Alex
Do you administer that page? Does the page make the status updates publicly visible?
SB
yep im an administrator, page is at http://www.facebook.com/milujikavu and everything is set to public
Alex
What kind of application are you going to be developing for this? If it's a backend web service, you could do the token acquisition in the backend with your creds and use the facebook APIs transparently. Then your frontend could just make api calls to your backend.
SB
Thanks again by the way, the application is just getting the current Status of a non-profile page I'm an admin of. I was hoping to use PHP to do this (via http://github.com/facebook/php-sdk/) so I could retrieve the data and then just show it as static text. I've created a dummy application and added it to the page but I don't know what credentials to use to access the pages Status
Alex
You can acquire a long lived token using the extended permissions (see the offline_access permission) and use that token in your backend. You can do the token acquisition offline, put it in your PHP, and then use the SDK with that token. It's not the most secure if you're sharing the PHP around, but end-users of your app won't see it since it all happens on the backend. See http://developers.facebook.com/docs/authentication/permissions
SB
A: 

I finally found out that this doesn't have to be done through the API, or require any authentication at all.

Basically you can access the data via a JSON feed:

$pageID = "ID of Page" //supply the Id of the fan page you want to access
$url = "https://graph.facebook.com/". $pageID ."/feed";
$json = file_get_contents($url);
$jsonData = json_decode($json);

foreach($jsonData->data as $val) {
    if($val->from->id == $pageID) { //find the first matching post/status by a fan page admin
        $message = $val->message;
        echo $message;
        break; //stop looping on most recent status posted by page admin
    }
}

full post -> http://www.ajgraham.com/2010/07/get-facebook-page-stream-simple-easy/

Alex