Discussion Forums  >  Plugins, Customizing, Source Code

Replies: 7    Views: 756

AppGuy30
Code is Art
Profile
Posts: 737
Reg: Oct 29, 2011
location unknow...
14,070
03/10/12 09:35 AM (13 years ago)

Display facebook status and posts (new code!!)

Ever wanted to display your facebook posts...well now you can. 1) Sign in as a developer at: https://www.facebook.com/developers/ 2) Click on ‘Set up a new app’. Follow the steps and this will give you an ID and an App Secret. 3) You can then go to this URL to get your Access Token: ‘https://graph.facebook.com/oauth/access_token?grant_type=client_credentials&client_id=CLIENT_ID&client_secret=CLIENT_SECRET’, replacing CLIENT_ID and CLIENT_SECRET with your ID and App Secret from step 2. 4) You can then access the Facebook data feed as JSON data at the following URL: ’https://graph.facebook.com/PAGE_ID/feed?access_token=ACCESS_TOKEN’, replacing PAGE_ID with your page, group or profile ID, and ACCESS_TOKEN with the Access Token you were given in step 3. Note: Your page, group or profile ID can be found in its URL. Eg. ’http://www.facebook.com/group.php?gid=102037668290′, the ID would be the numbers after the ‘gid?=’. 5) You can then display the feed using a little PHP.. something like this: <?php //Get the contents of the Facebook page $FBpage = file_get_contents('https://graph.facebook.com/PAGE_ID/feed?access_token=ACCESS_TOKEN'); //Interpret data with JSON $FBdata = json_decode($FBpage); //Loop through data for each news item foreach ($FBdata->data as $news ) { //Explode News and Page ID's into 2 values $StatusID = explode("_", $news->id); echo '<li>' //Check for empty status (for example on shared link only) if (!empty($news->message)) { echo $news->message;} echo '</li>' } ?> This just displays the text status updates from a particular group, page or profile. It’s possible to display images, links and even video, but that’s beyond the scope of this short tutorial. Any comments or questions, let me know! Cheers! Source: http://johndoesdesign.com/blog/2011/php/adding-a-facebook-news-status-feed-to-a-website/
 
Fred@mySkylla com
Android Fan
Profile
Posts: 5259
Reg: Oct 03, 2011
location unknow...
62,560
like
03/10/12 10:59 AM (13 years ago)
Are you johndoes? Fred
 
Stefan
buzztouch Evangelist
Profile
Posts: 558
Reg: Dec 21, 2010
Sweden
14,780
like
03/10/12 11:35 AM (13 years ago)
Great tip - thanks for sharing. BR/Stefan
 
AppGuy30
Code is Art
Profile
Posts: 737
Reg: Oct 29, 2011
location unknow...
14,070
like
03/10/12 12:18 PM (13 years ago)
Haha no @fred in not johndoes, it is just the website i found it at.
 
chux.isuru
Android Fan
Profile
Posts: 4
Reg: Jan 23, 2012
location unknow...
40
like
03/19/12 10:52 PM (13 years ago)
Thanks mate! It is really Useful!
 
ATRAIN53
Code is Art
Profile
Posts: 1755
Reg: Nov 17, 2011
Chicago
26,450
like
03/28/12 01:52 PM (13 years ago)
Thanks, was just lookign for a way to display the facebook posts like the twitter RSS feed. i was looking at this: http://ahrengot.com/tutorials/facebook-rss-feed/ but i notice in the comments people keep saying 'FB changed again' and their feeds no longer work. does this method also display the replies to posts? is anyone using this in a APP?
 
AppGuy30
Code is Art
Profile
Posts: 737
Reg: Oct 29, 2011
location unknow...
14,070
like
03/28/12 04:55 PM (13 years ago)
no it dosent
 
cliffmcl
Android Fan
Profile
Posts: 1
Reg: Aug 20, 2012
Belfast
3,260
like
08/28/12 01:52 PM (13 years ago)
Hi I'd love to use this but can't work out how to incorporate it in an APP. I'd really appreciate a dummies' guide to gettingthe PHP to run in Buzztouch. Thanks
 

Login + Screen Name Required to Post

pointerLogin to participate so you can start earning points. Once you're logged in (and have a screen name entered in your profile), you can subscribe to topics, follow users, and start learning how to make apps like the pros.