2014-07-24 55 views
2

即時通訊添加新聞提要圖片在我的會員網站,並需要幫助從新聞提要獲取大圖片。facebook api php新聞提要獲取大圖片

這是我的代碼來獲取新聞源圖片

$ 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新聞源數組的示例。

[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

這是合適的地方?或只是一個愚蠢的問題大聲笑?? :( –

+0

任何鏈接或教程將有所幫助??仍然無法得到它的工作:( –

回答

0

嘗試OBJECT_ID ....它爲我工作:)

echo '<img src="https://graph.facebook.com/' . $news_feed['object_id'] . '/picture?type=normal">' . '<br />'; 
相關問題