-
Notifications
You must be signed in to change notification settings - Fork 14
/
index.php
48 lines (36 loc) · 1.42 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?php
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
require_once __DIR__ .'/../vendor/autoload.php';
use Dotenv\Dotenv;
// load envirionment variable
// add this package in your composer.json if want to use dotenv "vlucas/phpdotenv"
$env = new Dotenv(__DIR__ . '/../');
$env->load();
// set page
$fbSecretKey = getenv('FB_SECRET_KEY');
$fbAppId = getenv('FB_APP_ID');
$fbPageName = getenv('FB_PAGENAME');
$accessToken = getenv('FB_ACCESS_TOKEN');
// Example 1
//$response = fb_feed()->setAppId($fbAppId)->setSecretKey($fbSecretKey)->setPage($fbPageName)->findKeyword("#tutorial")->fetch();
// Example 2
//$response = fb_feed()->setCredential($fbAppId, $fbSecretKey)->setPage($fbPageName)->findKeyword("#tutorial")->fetch();
// Example 3
//$response = fb_feed()->findKeyword("#tutorial")->fetch();
// Example 4
//$response = fb_feed()->findKeyword(['#tutorial', '#tips'])->fetch();
// Example 5 - to fetch owner's pages only. Apps review not required
$response = fb_feed()
->setAccessToken($accessToken)
->setPage("yourpage")
->setModule("posts")
->fields(["id","message","created_time","from","permalink_url","full_picture"])
->fetch();
// Example 6
//$response = fb_feed()->fetch();
header('Content-type: application/json');
echo json_encode($response, JSON_PRETTY_PRINT);