From 19e79a166b20f103f1206645f4ed34ee7013af60 Mon Sep 17 00:00:00 2001 From: Romain Monteil Date: Fri, 10 Mar 2017 09:40:54 +0100 Subject: [PATCH] [fix #20] Add ending slash to base_uri, change routes to relative paths --- .scrutinizer.yml | 2 +- .travis.yml | 4 ++-- composer.json | 10 ++++++++-- src/Api/Send.php | 4 ++-- src/Api/Thread.php | 4 ++-- src/Api/User.php | 2 +- src/Api/Webhook.php | 2 +- src/Messenger.php | 2 +- 8 files changed, 18 insertions(+), 12 deletions(-) diff --git a/.scrutinizer.yml b/.scrutinizer.yml index 35fc7ca..5f71702 100644 --- a/.scrutinizer.yml +++ b/.scrutinizer.yml @@ -28,7 +28,7 @@ build: tests: override: - - command: 'phpunit --coverage-clover=clover.xml' + command: 'vendor/bin/phpunit --coverage-clover=clover.xml' coverage: file: 'clover.xml' format: 'clover' \ No newline at end of file diff --git a/.travis.yml b/.travis.yml index 4bd65b5..ebcf8b7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -32,9 +32,9 @@ before_script: - sh -c "if [ '$COVERALLS' = '1' ]; then mkdir -p build/logs; fi" script: - - sh -c "if [ '$COVERALLS' = '1' ]; then phpunit --stderr --coverage-clover build/logs/clover.xml; fi" + - sh -c "if [ '$COVERALLS' = '1' ]; then vendor/bin/phpunit --stderr --coverage-clover build/logs/clover.xml; fi" - sh -c "if [ '$COVERALLS' = '1' ]; then php vendor/bin/coveralls -v; fi" - - sh -c "if [ '$DEFAULT' = '1' ]; then phpunit --stderr; fi" + - sh -c "if [ '$DEFAULT' = '1' ]; then vendor/bin/phpunit --stderr; fi" - sh -c "if [ '$PHPCS' = '1' ]; then ./vendor/bin/phpcs -n -p --extensions=php --standard=PSR2 --ignore=vendor --ignore=tests . ; fi" notifications: diff --git a/composer.json b/composer.json index 258fddb..02b20e3 100644 --- a/composer.json +++ b/composer.json @@ -2,7 +2,13 @@ "name": "kerox/messenger", "type": "library", "description": "PHP Library for Facebook Messenger", - "keywords": ["facebook", "messenger", "facebook messenger", "bot messenger", "api"], + "keywords": [ + "facebook", + "messenger", + "facebook messenger", + "bot messenger", + "api" + ], "homepage": "https://github.com/ker0x/messenger", "license": "MIT", "authors": [ @@ -18,7 +24,7 @@ "guzzlehttp/guzzle": "^6.2" }, "require-dev": { - "phpunit/phpunit": "^5.6", + "phpunit/phpunit": "^6.0", "satooshi/php-coveralls": "^1.0", "squizlabs/php_codesniffer": "^2.7" }, diff --git a/src/Api/Send.php b/src/Api/Send.php index 45f781f..e53fe6f 100644 --- a/src/Api/Send.php +++ b/src/Api/Send.php @@ -41,7 +41,7 @@ public function sendMessage(string $recipient, $message, string $notificationTyp $this->isValidNotificationType($notificationType); $request = new SendRequest($this->pageToken, $recipient, $message, null, $notificationType); - $response = $this->client->post('/me/messages', $request->build()); + $response = $this->client->post('me/messages', $request->build()); return new SendResponse($response); } @@ -58,7 +58,7 @@ public function sendAction(string $recipient, string $action, string $notificati $this->isValidNotificationType($notificationType); $request = new SendRequest($this->pageToken, $recipient, null, $action, $notificationType); - $response = $this->client->post('/me/messages', $request->build()); + $response = $this->client->post('me/messages', $request->build()); return new SendResponse($response); } diff --git a/src/Api/Thread.php b/src/Api/Thread.php index 446be72..0fa054d 100644 --- a/src/Api/Thread.php +++ b/src/Api/Thread.php @@ -27,7 +27,7 @@ public function __construct($pageToken, ClientInterface $client) public function addSetting(ThreadSettings $threadSettings): ThreadResponse { $request = new ThreadRequest($this->pageToken, $threadSettings); - $response = $this->client->post('/me/thread_settings', $request->build()); + $response = $this->client->post('me/thread_settings', $request->build()); return new ThreadResponse($response); } @@ -44,7 +44,7 @@ public function deleteSetting(string $type, string $state = null) $threadSettings = new ThreadSettings($type, $state); $request = new ThreadRequest($this->pageToken, $threadSettings); - $this->client->delete('/me/thread_settings', $request->build()); + $this->client->delete('me/thread_settings', $request->build()); } /** diff --git a/src/Api/User.php b/src/Api/User.php index 5df19a2..7d07190 100644 --- a/src/Api/User.php +++ b/src/Api/User.php @@ -39,7 +39,7 @@ public function getProfile(string $userId, array $fields = null): UserResponse } $request = new UserRequest($this->pageToken, $fields); - $response = $this->client->get(sprintf('/%s', $userId), $request->build()); + $response = $this->client->get(sprintf('%s', $userId), $request->build()); return new UserResponse($response); } diff --git a/src/Api/Webhook.php b/src/Api/Webhook.php index d5bebf0..079952c 100644 --- a/src/Api/Webhook.php +++ b/src/Api/Webhook.php @@ -92,7 +92,7 @@ public function getChallenge() public function sendSubscribe(): WebhookResponse { $request = new WebhookRequest($this->pageToken); - $response = $this->client->post('/me/subscribed_apps', $request->build()); + $response = $this->client->post('me/subscribed_apps', $request->build()); return new WebhookResponse($response); } diff --git a/src/Messenger.php b/src/Messenger.php index 3609eec..c4ea42c 100644 --- a/src/Messenger.php +++ b/src/Messenger.php @@ -71,7 +71,7 @@ public function __construct(string $appSecret, string $verifyToken, string $page if ($client === null) { $client = new Client([ - 'base_uri' => self::API_URL . self::API_VERSION, + 'base_uri' => self::API_URL . self::API_VERSION . '/', ]); } $this->client = $client;