Posted By

rliverman on 03/15/12


Tagged

php rss wordpress embed simple pie facebook


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

mprough
Priestd09


Facebook Retrieve Recent Facebook Post(s) with Simple Pie RSS and PHP


 / Published in: PHP
 

Relies on "trunCate" a truncating function.

  1. // Recent facebooks function
  2. function recentFacebooks($fbID, $number){
  3. include_once(ABSPATH.WPINC.'/rss.php');
  4.  
  5. $fbpost = fetch_feed("http://www.facebook.com/feeds/page.php?id=" . $fbID . "&format=rss20");
  6.  
  7. if (!is_wp_error( $fbpost ) ) :
  8. $maxitems = $fbpost->get_item_quantity($number);
  9. $rss_items = $fbpost->get_items(0, $maxitems);
  10. endif;
  11.  
  12. if ($maxitems == 0) echo '<p>No Recent Posts.</p>';
  13. else foreach ( $rss_items as $item ){
  14.  
  15. $content = html_entity_decode($item->get_content());
  16. $cutcontent = trunCate($content,160, " ");
  17.  
  18. echo '<p>' . $cutcontent . '</p>';
  19. }
  20. }

Report this snippet  

You need to login to post a comment.