Skip to content

Commit

Permalink
Merge pull request #170 from gabriel-tandil/master
Browse files Browse the repository at this point in the history
add appsecret_proof support, useful for post 2.8 api version
  • Loading branch information
wittfabian authored Apr 13, 2019
2 parents 5809e03 + 63d1bf1 commit 582b6b9
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
## v1.2.2 (in development)

### New features & improvements:
- Add appsecret_proof support

### Bug fixes:
- Hotfixes in class FbBotApp
Expand Down
19 changes: 16 additions & 3 deletions FbBotApp.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ class FbBotApp
*/
protected $token = null;

/**
* @var null|string
*/
protected $appsecret_proof = null;

/**
* Contains the last cURL error for the current session if encountered
Expand All @@ -59,15 +63,20 @@ class FbBotApp
* FbBotApp constructor.
* @param string $token
* @param string $version optional
* @param string $app_secret optional
*/
public function __construct($token, $version = null)
public function __construct($token, $version = null, $app_secret=null)
{
$this->token = $token;

if (is_null($version)) {
$version = $this->apiVersion
$version = $this->apiVersion;
}


if (!is_null($app_secret)) {
$this->appsecret_proof = hash_hmac('sha256', $this->token, $app_secret);
}

$this->apiUrl = $this->baseApiUrl . $version . "/";
}

Expand Down Expand Up @@ -518,6 +527,10 @@ public function call($url, $data, $type = self::TYPE_POST)
{
$data['access_token'] = $this->token;

if (!is_null($this->appsecret_proof)){
$data['appsecret_proof'] = $this->appsecret_proof;
}

$headers = [
'Content-Type: application/json',
];
Expand Down

0 comments on commit 582b6b9

Please sign in to comment.