diff --git a/CHANGELOG b/CHANGELOG index 04a6bec..3938970 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,5 @@ +v1.1.1: + - Issue 28 - Fix for Cloud Front returning 403 with an empty json object for the request content v1.1.0: - Added support for the following API endpoints: /survey_languages diff --git a/README.md b/README.md index e870206..b9a4fb2 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ A simple SurveyMonkey API wrapper for version 3 of their API. Add the following to your composer.json under require: "require": { - "ghassani/surveymonkey-v3-api-php": "1.1.0" + "ghassani/surveymonkey-v3-api-php": "1.*" }, # Usage diff --git a/composer.json b/composer.json index 729e777..a55b03a 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,6 @@ { "name": "ghassani/surveymonkey-v3-api-php", - "version" : "1.1.0", + "version" : "1.1.2", "authors": [ { "name": "Gassan Idriss", diff --git a/src/Api/CollectorsTrait.php b/src/Api/CollectorsTrait.php index e5f7db8..7dfdc82 100644 --- a/src/Api/CollectorsTrait.php +++ b/src/Api/CollectorsTrait.php @@ -172,12 +172,10 @@ public function createCollectorMessage($collectorId, array $data = []) public function copyCollectorMessage($collectorId, $fromCollectorId, $fromMessageId, $includeRecipients = false) { return $this->sendRequest( - $this->createRequest('POST', sprintf('collectors/%s/messages', $collectorId), [ - 'query' => [ - 'from_collector_id' => $fromCollectorId, - 'from_message_id' => $fromMessageId, - 'include_recipients' => (bool)$includeRecipients, - ] + $this->createRequest('POST', sprintf('collectors/%s/messages', $collectorId), [], [ + 'from_collector_id' => (string)$fromCollectorId, + 'from_message_id' => (string)$fromMessageId, + 'include_recipients' => (bool)$includeRecipients, ]) ); } @@ -265,7 +263,7 @@ public function deleteCollectorMessage($collectorId, $messageId) */ public function sendCollectorMessage($collectorId, $messageId, \DateTime $scheduledDate = null) { - $data = $scheduledDate ? [ 'scheduled_date' => $scheduledDate->format(DATE_ATOM) ] : []; + $data = $scheduledDate ? [ 'scheduled_date' => $scheduledDate->format(DATE_ATOM) ] : new \stdClass(); return $this->sendRequest( $this->createRequest('POST', sprintf('collectors/%s/messages/%s/send', $collectorId, $messageId), [], $data) diff --git a/src/Client.php b/src/Client.php index c47b958..300f78e 100644 --- a/src/Client.php +++ b/src/Client.php @@ -152,10 +152,11 @@ public function sendRequest(RequestInterface $request) private function createRequest($method, $uri, array $options = [], $body = null) { if (empty($body)) { - // Empty arrays and NULL data inputs both need casting to an empty JSON object. - // See https://stackoverflow.com/a/41150809/2803757 - $bodyString = '{}'; - } elseif (is_array($body)) { + // Survey Monkey moved to CloudFront on 2020-05-23 + // CloudFront issues 403 Forbidden with empty json body + // Previously this was set to an empty json object string. See https://stackoverflow.com/a/41150809/2803757 + $bodyString = null; + } elseif (is_array($body) || $body instanceof \stdClass) { $bodyString = json_encode($body); }