Search code examples
facebookimagestatus

facebook status on web with picture


Finally i got this done with the likes and statuses but I would like to ask for help if it is possible somehow to transfer also the pictures on web. thank you

 <?php
   $facebook_page_id = '**********';
   $access_token = '************';
   $number_of_posts = 2;

   $json_content = file_get_contents('http://graph.facebook.com/'.$facebook_page_id.'/feed?access_token='.$access_token);

   $raw_data = json_decode($json_content);
   $i=0; 
   foreach ($raw_data->data as $feed ) {
   $feed_id = explode("_", $feed->id);
   if (!empty($feed->message)) { 
          $i++;
          if ($i<($number_of_posts+1)) {
?>

    <div class=”fb_update”>
    <?php if (!empty($feed->likes->count)) { ?>
    <div class=”fb_likes”>
    <?php echo $feed->likes->count; ?>
    </div>
    <?php }       ?>  
    <?php if (!empty($feed->created_time)) { ?>
    <div class=”fb_date”>
          <?php echo date('F j, Y', strtotime($feed->created_time)); ?>
    </div>
    <?php }       ?>
      <div class=”fb_message”>
     <?php echo $feed->message; ?>
   </div>       
   </div>

   <?php } ?>
   <?php } ?>
   <?php } ?>

Solution

  • Yes, $feed->picture will get you the URL to an image for a particular item, if it exists.

    You should really look at using cURL via the PHP SDK for this instead of file_get_contents(). It is more robust.