PHP code example of xmhafiz / fb-page-feed

1. Go to this page and download the library: Download xmhafiz/fb-page-feed library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

xmhafiz / fb-page-feed example snippets


$data = fb_feed()->setAppId($fbAppId)
        ->setSecretKey($fbSecretKey)
        ->setPage($fbPageName)
        ->fetch();

$data = fb_feed()->fetch(); // must have .env

$config = [
    'secret_key' => '',
    'app_id' => '',
    'page_name' => '',
    'access_token' => '',
];
$data = fb_feed($config)->fetch();
$data = FbFeed::make($config)->fetch();


$data = fb_feed()->setAppId($fbAppId)
        ->setSecretKey($fbSecretKey)
        ->setPage($fbPageName)
        ->fetch();

$data = fb_feed()->setAppId($fbAppId)
        ->setSecretKey($fbSecretKey)
        ->setPage($fbPageName)
        ->setModule("feeds")
        ->fetch();

// only show 5 post maximum
$data = fb_feed()->setAppId($fbAppId)
        ->setSecretKey($fbSecretKey)
        ->setPage($fbPageName)
        ->feedLimit(5)
        ->fetch();

// only show 5 post maximum
$data = fb_feed()->setAppId($fbAppId)
        ->setSecretKey($fbSecretKey)
        ->setPage($fbPageName)
        ->findKeyword("#LaravelCommunity")
        ->fetch();

// only show 5 post maximum
$data = fb_feed()->setAppId($fbAppId)
        ->setSecretKey($fbSecretKey)
        ->setPage($fbPageName)
        ->fields("id,message") //default 'id,message,created_time' 
        ->fields(["id","message"]) // can be array
        ->fetch();

$data = fb_feed()
        ->setAccessToken($userAccessToken)
        ->setPage($fbPageName)
        ->fetch();



cretKey='580c7...';
$fbAppId='237...';
$fbPageName='LaravelCommunity';

$response = fb_feed()->setAppId($fbAppId)->setSecretKey($fbSecretKey)->setPage($fbPageName)->findKeyword("#tutorial")->fetch();

//or

$response = fb_feed()->setCredential($fbAppId, $fbSecretKey)->setPage($fbPageName)->findKeyword("#tutorial")->fetch();

header('Content-type: application/json');
echo json_encode($data);