Get latest Facebook posts of page with PHP SDK

后端 未结 4 1614
傲寒
傲寒 2021-01-31 12:05

The following code is inside a file called facebook_posts.php which I call from my index file like so:

4条回答
  •  感情败类
    2021-01-31 13:00

    all what you need to get latest posts from facebook feed is described here: http://piotrpasich.com/facebook-fanpage-feed/

    In shortcut - use your fanpage feed (please replace {id} by proper id)

    https://facebook.com/feeds/page.php?format=atom10&id={id}

    You can download the feed with this piece of code:

    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, $rss_url);
    curl_setopt($curl, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.0.3705; .NET CLR 1.1.4322; Media Center PC 4.0)');
    curl_setopt($curl, CURLOPT_REFERER, '');
    curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($curl, CURLOPT_TIMEOUT, 10);
    $raw_xml = curl_exec($curl); // execute the curl command
    

提交回复
热议问题