How to get the large picture from feed with graph api?

前端 未结 9 1658
灰色年华
灰色年华 2020-12-08 05:14

When loading the Facebook feeds from one page, if a picture exist in the feed, I want to display the large picture.

How can I get with the graph API ? T

9条回答
  •  鱼传尺愫
    2020-12-08 05:44

    Thanks to @mattdlockyer for the JS solution. Here is a similar thing in PHP:

    $posts = $facebook->api('/[page]/posts/', 'get');
    
    foreach($posts['data'] as $post)
    {
        if(stristr(@$post['picture'], '_s.'))
        {
            $post['picture'] = str_replace('_s.', '_n.', @$post['picture']);
        }
    
        if(stristr(@$post['picture'], 'url='))
        {
            parse_str($post['picture'], $picturearr);
            if($picturearr['url'])
                $post['picture'] = $picturearr['url'];
        }
    
        //do more stuff with $post and $post['picture'] ...
    }
    

提交回复
热议问题