Ajouve
Ajouve

Reputation: 10089

get facebook feed with facebook api

I'd like to facebook page feed on my website but I need an access tosken for that

public function newsFacebookAction() {
    require './application/libraries/facebook-php-sdk/src/facebook.php';

    $facebook = new Facebook( array('appId' => FACEBOOK_KEY, 'secret' => FACEBOOK_SECRET, ));

    // Get User ID
    $user = $facebook -> getUser();

    $args['var']['user'] = $user;

    if ($user) {
        $args['var']['url'] = $facebook -> getLogoutUrl();
        // Get the current access token
        $access_token = $facebook -> getAccessToken();
        //get feed
        $helper = new Helper();
        $args['var']['feed'] = $helper->get_web_page("https://graph.facebook.com/OfficielAssas.net/feed?access_token=".$access_token);
    } else {
        $args['var']['url'] = $facebook -> getLoginUrl();
    }
}

get_web_page is this function

http://nadeausoftware.com/articles/2007/06/php_tip_how_get_web_page_using_curl

I have the error:

SSL certificate problem, verify that the CA cert is OK. Details: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed

bur if I derectly go to the address this works fine

Thanks

Upvotes: 0

Views: 3432

Answers (1)

cpilko
cpilko

Reputation: 11852

You're over-complicating things. You've got the Facebook API. Why not use it?

public function newsFacebookAction() {
require './application/libraries/facebook-php-sdk/src/facebook.php';

$facebook = new Facebook( array('appId' => FACEBOOK_KEY, 'secret' => FACEBOOK_SECRET, ));
$result = $facebook->api('/OfficielAssas.net/feed', 'GET');
print_r($result);

You can query the values of a page (so long as there are no age or country restrictions) without authenticating a user.

Upvotes: 2

Related Questions