Skip to content

Commit

Permalink
update readme and examples for using userAccessToken
Browse files Browse the repository at this point in the history
  • Loading branch information
xmhafiz committed Dec 14, 2018
1 parent 60d0f0f commit 4bb860a
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 6 deletions.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,16 @@ $data = fb_feed()->setAppId($fbAppId)
->fetch();
```

#### To get owner's fb page feed using userAccessToken

Details to get `userAccessToken` can refer [here](https://github.com/xmhafiz/fb-page-feed/pull/7).

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

## Code Example

Expand Down
16 changes: 13 additions & 3 deletions example/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,25 @@
$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();
//or
// Example 2
$response = fb_feed()->setCredential($fbAppId, $fbSecretKey)->setPage($fbPageName)->findKeyword("#tutorial")->fetch();
//or

// Example 3
$response = fb_feed()->findKeyword("#tutorial")->fetch();
//or

// 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)->fetch();

// Example 6
$response = fb_feed()->fetch();

header('Content-type: application/json');
echo json_encode($response, JSON_PRETTY_PRINT);

5 changes: 2 additions & 3 deletions src/FbFeed.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ public function __construct()
$this->access_token = getenv('FB_ACCESS_TOKEN');
}


/**
* @param $app_id
* @return $this
Expand Down Expand Up @@ -115,11 +114,11 @@ function fetch() {
return $this->returnFailed('Page Name is needed');
}

if (!$this->app_id&&!$this->access_token) {
if (!$this->app_id &&! $this->access_token) {
return $this->returnFailed('Facebook App ID is needed. Please refer to https://developers.facebook.com');
}

if (!$this->secret_key&&!$this->access_token) {
if (!$this->secret_key &&! $this->access_token) {
return $this->returnFailed('Facebook Secret Key is needed. Please refer to https://developers.facebook.com');
}

Expand Down

0 comments on commit 4bb860a

Please sign in to comment.