Reputation: 187
im adding news feed pictures in my members site and need help getting the large pictures from the news feed.
This is my code to get the news feed pictures
$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 />';
}
This give me the news feed pictures fine but all different sizes.
any help would be good!
I have looked around for a long time and still cant find the answer?
this is a example of a facebook news feed array i am trying to get the large picture from.
[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
I belive I have to change the _n.jpg to _b.jpg or p130x130 to b740x740 but the function is not working ??
I have tryed running this function before/after the foreach loop. But it is still not working?
$news_feed ['picture'] = str_replace("_n.jpg", "_b.jpg", $news_feed['picture']);
also this
$news_feed ['picture'] = str_replace("p130x130", "b740x740", $news_feed['picture']);
can some one please help, :( thanks
Upvotes: 2
Views: 575
Reputation: 187
Try object_id ....it worked for me :)
echo '<img src="https://graph.facebook.com/' . $news_feed['object_id'] . '/picture?type=normal">' . '<br />';
Upvotes: 1