我正在使用图形API来获取要访问的令牌,该访问使用我的Facebook页面上要使用的引用“ pagename?fields = picture”进行引用。 这是我正在使用的功能;
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;
}
这用于获取和显示图像以及标题和日期;
<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>
问题是我在运行时遇到此错误; $ 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"
}
}
代码和一切运行正常,并且已在2个月前停止。谁能告诉我为什么full_picture不存在?这是否意味着我们不能再将full_picture参数用于页面?任何帮助表示赞赏! :)
答案 0 :(得分:0)
代码和一切工作正常,facebook尚未更改以上文章中使用的任何参数。我访问的令牌存在一些问题,我生成了一个新的令牌,它现在开始工作。谢谢!