Full_picture Parameter for page

357 Views Asked by At

I am using graph API to get access tokken using a reference "pagename?fields=picture" for my facebook page to be used on my website. This is the function that I am using;

    function get_facebook_post_pic_full_url($feed_id)
    {   
        echo "<script>console.log( 'Debug Objects: " . $feed_id . "' );</script>";  
        $ursls = 'https://graph.facebook.com/'.$feed_id.'/?fields=full_picture,picture&access_token="Access Tokken"';
        $fb_act = json_decode(file_get_contents($ursls));
        return $fb_act;
    }


function get_facebook_page_feed($fts_limiter='')
{
    if(!$fts_limiter)
    {
      $fts_limiter = 1;
    }

    $pageid = get_field('facebook_page_id','option');

    //If there's no Access Token then use a default
    $access_token_array = array(
        'sampleaccess tokken'
 'sampleaccess tokken'
 'sampleaccess tokken'
    );

    $access_token = $access_token_array[rand(0, 11)];

    $graph_data = 'https://graph.facebook.com/'.$pageid.'/posts?fields=id,from,message,story,story_tags,link,source,name,caption,description,type,status_type,object_id,attachments,created_time&access_token='.$access_token.'&limit=1&locale=en_US';

    $fb_activity = json_decode(file_get_contents($graph_data));
    return $fb_activity;
}

And this is used to fetch and display image and caption and date;

 <div class="col-xs-12 col-sm-6 col-md-4 no-padding">
<div class="facebook_img">
  <?php
  $fb_feeds = get_facebook_page_feed();

  if(!empty($fb_feeds)):

        $feeds = $fb_feeds->data[0];
        $created_time = $feeds->created_time;
        $link = $feeds->link;
        $feed_id = $feeds->id;

        $full_arr = get_facebook_post_pic_full_url($feed_id);

        $full_picture = $full_arr->full_picture;
        $message = $feeds->message;
        $submessage = substr($message,0,75);

    ?>
    <!--<?php  var_dump($full_arr);?> -->
  <img style="width:405px;height:341px" src="<?php echo $full_picture; ?>" alt="facebook"/>
  <div class="fb_content"> <a target="_blank" href="<?php echo $link; ?>"><?php echo $submessage; ?></a>
    <dt><?php echo date('d/m/Y', strtotime($created_time)); ?></dt>
  </div>
  <?php endif; ?>
</div>

The issue is that I am getting this error when I run; $ursls = 'https://graph.facebook.com/'.$feed_id.'/?fields=full_picture,picture&access_token="Access Tokken"';

{
   "error": {
      "message": "(#100) Tried accessing nonexisting field (full_picture) on node type (Page)",
      "type": "OAuthException",
      "code": 100,
      "fbtrace_id": "traceid"
   }
}

The code and everything was working fine and it has stopped 2 months ago. Can anyone please tell me why full_picture is nonexisting field? Does that mean that we can not use full_picture parameter for page anymore? Any help is appreciated! :)

1

There are 1 best solutions below

0
sundasmunir On BEST ANSWER

The code and everything is working fine and facebook has not changed any parameters that are used in the above post. My access tokken was having some issues, I generated a new one and it started to work now. Thank you!