A community in which webmasters can ask for help with topics such as PHP coding , MySQL , IT jobs, web design, IT security.
Current location:homephp forumphp talk in 2008 yearPHP function to get Facebook status? - page 1
User InfoPosts
PHP function to get Facebook status?#1
I'm looking for a good, simple PHP function to get my latest Facebook status updates. Anyone know of one?


EDIT: I've added a half-solution below.

Or if anyone knows a good way to read in the RSS feed and spit out the recent status update?

posted date: 2008-12-20 13:44:00

Re: PHP function to get Facebook status?#2
I had made out the solution of this problem. click to view my topic...

hope that hepls.

posted date: 2008-12-20 13:44:01

Re: PHP function to get Facebook status?#3
A quick check on PEAR found Services_Facebook

posted date: 2008-12-20 13:53:00

Re: PHP function to get Facebook status?#4
I never seem to get along with PEAR, but if you have better luck than I, then the PEAR solution seems the best route long term.Another idea is to explore the Facebook Developer API library and see if that might give you anything you are looking for.Lastly, there used to be a way to get an RSS feed... but I can't seem to find any instructions that work anymore, but you might poke around Facebook help if that interests you. Mine ends up looking something like this:http://www.new.facebook.com/feeds/status.php?id=[idnumber]&viewer=[viewer]&key=[key]&format=rss20

posted date: 2008-12-20 14:09:00

Re: PHP function to get Facebook status?#5
Interesting question. I want that answer too!

posted date: 2008-12-20 14:17:00

Re: PHP function to get Facebook status?#6
This is an incomplete answer, but this is what I've gotten so far:First: add the developer application on FB. Then create a new application. Call it whatever you want.Second: Download the PHP client. Dump it somewhere on your webhost, i.e. /facebook/Third: Copy the following beginner code to get yourself started into a php file: <?php require_once('facebook/php/facebook.php'); $facebook = new Facebook("YOUR_API_KEY","YOUR_SECRET_KEY"); $result = $facebook->api_client->fql_query("SELECT status FROM user WHERE uid = YOURIDNUMBER"); // OR --- they both get the same data $result = $facebook->api_client->users_getInfo(YOURIDNUMBER,'status'); print_r($result); echo "<pre>Debug:" . print_r($facebook,true) . "</pre>"; // debug info ?>Other info:You must be logged in and have theapplication added. OR you give theapplication offline_accesspermissions and have theaapplication added.You can add offline_access by typingin the following url:http://www.facebook.com/authorize.php?api_key=YOUR_API_KEY&v=1.0&ext_perm=offline_accessmore info on permissions found here: http://wiki.developers.facebook.com/index.php/Extended_permissionsI'm at a stopping point: anything myprogram calls the fql query orusers_getInfo, my page stopsexecuting the php? I'm guessingthere are a limited amount of callsfor new applications? I've neverdone any FB development so I'mcompletely new to it. Maybe makethe call and save your recent status(or most recent statuses) in yourown DB to prevent excessive calls tothe API?I hope this helps someone get started! EDIT: It seems that FB won't let you access someones status, even if the offline_access is on, unless you are that person or their friend (depending on their privacy settings).I did however, finally manage to find the RSS feed in the new profile version: http://www.new.facebook.com/minifeed.php?filter=11

posted date: 2008-12-21 01:03:00

Re: PHP function to get Facebook status?#7
You should be seeing something, somewhere. A blank output is usually a sign of a fatal error going to the apache error_log when you have display_errors = off in your php.ini. The FB client is nicely OO'ed PHP5 and generally throws quite meaningful and detailed exceptions in the event of an error.

posted date: 2008-12-21 01:21:00

Re: PHP function to get Facebook status?#8
I ended up resetting my SECRET key and that solved the problem. However, my fql query won't give any results unless I include: $fb_user = $facebook->require_login();. The offline_access permission doesn't seem to be working correctly or I'm going at this wrong.

posted date: 2008-12-21 01:37:00

Re: PHP function to get Facebook status?#9
Since I couldn't use the API route, I went with the RSS found at: http://www.new.facebook.com/minifeed.php?filter=11And used the following PHP function, called StatusPress, with some of my own modifications, to parse the RSS feed for my Facebook status. Works great!

posted date: 2009-01-04 11:35:00

Re: PHP function to get Facebook status?#10
<?php// see http://github.com/facebook/php-sdk/blob/master/facebook.phprequire './facebook.php';// Create our Application instance.// see http://www.youtube.com/watch?v=jYqx-RtmkeU for how to get these numbers$facebook = new Facebook(array('appId' => 'XXX','secret' => 'XXX'));// This call will always work since we are fetching public data.// this could be /username or /username/friends etc...// see developer api for FQL for examples$status = $facebook->api('/haanmc/feed?limit=1');?><p><?php print $status['data'][0]['message']; ?></p><p>Likes: <?php print $status['data'][0]['likes']; ?> | Comments: <?php print count($status['data'][0]['comments']['data']); ?></p><textarea style="width: 95%; height: 600px;"><?php print_r($status); ?></textarea>

posted date: 2010-04-23 07:29:00

Re: PHP function to get Facebook status?#11
I have found a way to fetch your latest facebook status. This is how you do it:1) Create a facebook app, and copy your application secret and application id.2) Grant the app read_stream and offline_access to your profile. (http://developers.facebook.com/docs/authentication/permissions) To fetch your latest status the app needs an access_token. With offline_access granted the access_token should "never" expire. The easiest way to do this is to click the button generated by this code: (be sure to fill in 'your app id' and set cookie to true!)<fb:login-button perms="read_stream,offline_access"></fb:login-button><div id="fb-root"></div><script src="http://connect.facebook.net/en_US/all.js"></script><script>FB.init({appId: 'your app id', status: true, cookie: true, xfbml: true});</script>3) Now try to find out what access_token it is using. The access_token is saved in the fbs_appId cookie. Locate it using your browser or using $_COOKIE['fbs_appId']. Look for access_token=....4) Now that you have a (hopefully) never expiring access_token you can use the following code:$access_token='xxxxxxxxxxxxxxxxxxxx';$appId='123456789132456789';$appSecret='xxxxxxxxxxxxxxxxxxxx';$profileId='123456789';//http://github.com/facebook/php-sdk/blob/master/src/facebook.phprequire 'facebook.php';$facebook = new Facebook(array('appId' => $appId,'secret' => $appSecret));$response = $facebook->api('/'.$profileId.'/feed?limit=1&access_token='.$access_token);5) The message part should be located: $response['data'][0]['message']I don't know HOW long the access token is valid. Facebook says:Enables your application to perform authorized requests on behalf of the user at any time. By default, most access tokens expire after a short time period to ensure applications only make requests on behalf of the user when the are actively using the application. This permission makes the access token returned by our OAuth endpoint long-lived.

posted date: 2010-04-27 00:56:00

Re: PHP function to get Facebook status?#12
Here's a working link to the PHP client: github.com/facebook/php-sdk

posted date: 2010-05-24 14:53:00

select page: « 1 2 »
Copyright ©2008-2017 www.momige.com, all rights reserved.