From 038063c6f2e1b6577f8d674ad2df1420032c85f6 Mon Sep 17 00:00:00 2001 From: gaby Date: Thu, 11 Apr 2019 16:24:52 -0300 Subject: [PATCH 1/3] add appsecret_proof support, useful for post 2.8 api version --- FbBotApp.php | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/FbBotApp.php b/FbBotApp.php index edc61de..c51d04b 100755 --- a/FbBotApp.php +++ b/FbBotApp.php @@ -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 @@ -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 . "/"; } @@ -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', ]; From 173946e88b544a8a38bf734379fccbcf1ff0fa7c Mon Sep 17 00:00:00 2001 From: Gabriel Date: Fri, 12 Apr 2019 08:42:13 -0300 Subject: [PATCH 2/3] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8136b37..ca6b49e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ ## v1.2.2 (in development) ### New features & improvements: +- Add appsecret_proof support ### Bug fixes: - Hotfixes in class FbBotApp From 63d1bf19bc9ad5cead5c030429f9a630132c3f97 Mon Sep 17 00:00:00 2001 From: Fabian Date: Sat, 13 Apr 2019 11:37:40 +0200 Subject: [PATCH 3/3] Update FbBotApp.php add space --- FbBotApp.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/FbBotApp.php b/FbBotApp.php index c51d04b..b880693 100755 --- a/FbBotApp.php +++ b/FbBotApp.php @@ -74,7 +74,7 @@ public function __construct($token, $version = null, $app_secret=null) } if (!is_null($app_secret)) { - $this->appsecret_proof= hash_hmac('sha256', $this->token, $app_secret); + $this->appsecret_proof = hash_hmac('sha256', $this->token, $app_secret); } $this->apiUrl = $this->baseApiUrl . $version . "/";