我在我的会员网站添加新闻提要图片,需要帮助从新闻提要中获取大图片。
这是我获取新闻Feed图片的代码
$ json_object = @file_get_contents(' https://graph.facebook.com/me/home?access_token='。$ fb_access_token); $ news_feeds = json_decode($ json_object,true);
foreach($news_feeds['data'] as $news_feed)
{
echo '<img src="' . $news_feed['picture'] . '" />' . '<br />';
}
这给我的新闻提要图片很好,但尺寸各不相同。
任何帮助都会很好!
我已经环顾了很长时间但仍无法找到答案?
这是一个facebook新闻Feed数组的示例,我试图从中获取大图。
[id] => 1423830694520861_1508536172716979
[from] => Array
(
[category] => Public figure
[name] => Dan Bilzerian
[id] => 1423830694520861
)
[to] => Array
(
[data] => Array
(
[0] => Array
(
[category] => Public figure
[name] => Jen Selter
[id] => 244183679061369
)
)
)
[message] => Happy 21st to Jen Selter and her #NeverEndingAss
[message_tags] => Array
(
[14] => Array
(
[0] => Array
(
[id] => 244183679061369
[name] => Jen Selter
[type] => page
[offset] => 14
[length] => 10
)
)
)
[picture] => https://scontent-b.xx.fbcdn.net/hphotos-xpf1/v/t1.0-9/p130x130/10563168_1508536129383650_2440015247017447728_n.jpg?oh=bfdb86c35b4b0ffe5a4ad9dbe65aba59&oe=54688CA7
[link] => https://www.facebook.com/danbilzerianofficial/photos/a.1425329161037681.1073741829.1423830694520861/1508536129383650/?type=1&relevant_count=1
[icon] => https://fbstatic-a.akamaihd.net/rsrc.php/v2/yx/r/og8V99JVf8G.gif
我相信我必须将_n.jpg改为_b.jpg 或者p130x130到b740x740但功能不起作用??
我试过在foreach循环之前/之后运行这个函数。但它仍然没有用?
$news_feed ['picture'] = str_replace("_n.jpg", "_b.jpg", $news_feed['picture']);
也是这个
$news_feed ['picture'] = str_replace("p130x130", "b740x740", $news_feed['picture']);
可以请一些人帮助,:(谢谢
答案 0 :(得分:0)
尝试object_id ....它对我有用:)
echo '<img src="https://graph.facebook.com/' . $news_feed['object_id'] . '/picture?type=normal">' . '<br />';