From e80e5d024166e220e53d05def639bca8748d003d Mon Sep 17 00:00:00 2001 From: Glyn Gray Date: Thu, 2 Jun 2022 16:00:10 -0700 Subject: [PATCH 1/3] Updated rmccue/requests v2 for PHP8.1 compatibility --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 76c383b..5b83422 100644 --- a/composer.json +++ b/composer.json @@ -16,7 +16,7 @@ } ], "require": { - "rmccue/requests": "^1.7" + "rmccue/requests": "^2.0" }, "config": { "sort-packages": true, From b4d2a3f9ecb107ced3f92d8c404a2e1b698590ff Mon Sep 17 00:00:00 2001 From: Glyn Gray Date: Thu, 2 Jun 2022 17:40:25 -0700 Subject: [PATCH 2/3] Added request update for PSR-4 fix --- src/API.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/API.php b/src/API.php index 80f42c9..1fc5135 100644 --- a/src/API.php +++ b/src/API.php @@ -11,7 +11,9 @@ namespace AhmadAwais\Sendy; -use Requests; +// use Requests; +// Switch to the PSR-4 class naming +use Symfony\Component\HttpFoundation\Request; use Exception; // Helps with the CORS issues. @@ -349,9 +351,9 @@ private function query( $route, array $values ) { // URL to send POST to. $postUrl = $this->sendyUrl . '/' . $route; - if ( class_exists( 'Requests' ) ) { + if ( class_exists( 'Request' ) ) { // Send POST. - $request = Requests::post( $postUrl, [], $postData ); + $request = Request::post( $postUrl, [], $postData ); $apiResponse = $request->body; } else { // Let's cURL. From 55d7745bbc13458e100a49d0d70f444f4da2d1fc Mon Sep 17 00:00:00 2001 From: Glyn Gray Date: Thu, 18 Jan 2024 22:19:11 -0800 Subject: [PATCH 3/3] Found headers which were invalidating cors. --- src/API.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/API.php b/src/API.php index 1fc5135..fa06b32 100644 --- a/src/API.php +++ b/src/API.php @@ -17,9 +17,10 @@ use Exception; // Helps with the CORS issues. -header( 'Access-Control-Allow-Origin: *' ); -header( 'Access-Control-Allow-Methods: POST, GET' ); -header( 'Access-Control-Allow-Credentials: true' ); +// These headers cause duplication. +#header( 'Access-Control-Allow-Origin: *' ); +#header( 'Access-Control-Allow-Methods: POST, GET' ); +#header( 'Access-Control-Allow-Credentials: true' ); /** * API Class.