Get wall feed from a public Facebook page using Graph API - is it really this complex?

前端 未结 3 688
悲哀的现实
悲哀的现实 2021-02-04 08:27

I have started off by reading Displaying Facebook posts to non-Facebook users which is of some use but I cannot believe it is this difficult to get a public feed from Facebook.<

相关标签:
3条回答
  • 2021-02-04 08:50

    Two years later, you can programmatically do this with a Facebook App (an example using PHP and Slim): https://developers.facebook.com/apps/

    $base_api="https://graph.facebook.com/";
    $client_id="XXXXXX";
    $app_secret="XXXXXX";
    
    //get a profile feed (can be from a page, user, event, group)
    $app->get('/feed/:profileid/since/:start_date', function ($profile_id,$start_date) {
    
        $start_time=date('m/d/Y h:i:s',$start_date);
    
        $request = new FacebookRequest(
          getSession(),
          'GET',
          '/'.$profile_id.'/feed?since='.$start_time
        );
    
        $response = $request->execute();
        $graphObject = $response->getGraphObject();
    
        //do something with $graphObject
    
    });
    
    
    function getSession(){
        $session = new FacebookSession(getAccessToken());
        return $session;
    }
    
    
    function getAccessToken(){
        global $base_api, $client_id, $app_secret;
        $url=$base_api."oauth/access_token?client_id=".$client_id."&client_secret=".$app_secret."&grant_type=client_credentials";
        $str = file_get_contents($url);
        $token = str_replace ( "access_token=" , "" , $str );
        return $token;
    }
    
    0 讨论(0)
  • 2021-02-04 08:55

    Facebook has changed how to retrieve a public Facebook page's feed since the other answers were posted.

    Check out my answer/question. It's not PHP, but it provides the URLs and process you need.

    0 讨论(0)
  • 2021-02-04 09:16

    I have some success with reading in the direct feed without tokens etc. (using magpie, simplepie or querypath or similar).

    http://www.facebook.com/feeds/page.php?format=rss20&id=........ http://www.facebook.com/feeds/page.php?format=atom10&id=........

    found on: http://ahrengot.com/tutorials/facebook-rss-feed/

    0 讨论(0)
提交回复
热议问题