From 0704be5a3ffe0e90cea016683502fbaa26b6a39b Mon Sep 17 00:00:00 2001 From: Mostafa Tarek <109668729+Mostafa7000@users.noreply.github.com> Date: Wed, 3 Jul 2024 00:22:31 +0300 Subject: [PATCH 1/3] FIX: avoid using current() on objects because it's deprecated Use `get_mangled_object_vars()` with the `current()` method to avoid a deprecation warning caused by using an object with `current()` function --- src/Response/VectoryLinkResponse.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Response/VectoryLinkResponse.php b/src/Response/VectoryLinkResponse.php index c1006d0..08041d7 100644 --- a/src/Response/VectoryLinkResponse.php +++ b/src/Response/VectoryLinkResponse.php @@ -32,7 +32,7 @@ final class VectoryLinkResponse implements SMSDriverResponseInterface public function __construct(ResponseInterface $response) { $this->response = new SimpleXMLElement($response->getBody()); - $this->status = (int) current($this->response); + $this->status = (int) current(get_mangled_object_vars($this->response)); } public function success(): bool From 3ad30586a49e1ed13e3e2ce55b88ea6542d447d0 Mon Sep 17 00:00:00 2001 From: Mostafa Tarek <109668729+Mostafa7000@users.noreply.github.com> Date: Wed, 3 Jul 2024 13:15:00 +0300 Subject: [PATCH 2/3] fix: use `x-www-form-urlencoded` type instead of `text/xml` This is tested using the following URL: https://smsvas.vlserv.com/KannelSending/service.asmx/SendSMS --- src/Drivers/VectoryLinkDriver.php | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/src/Drivers/VectoryLinkDriver.php b/src/Drivers/VectoryLinkDriver.php index ba0cc4b..e71acce 100644 --- a/src/Drivers/VectoryLinkDriver.php +++ b/src/Drivers/VectoryLinkDriver.php @@ -1,4 +1,5 @@ endPoint, $this->headers(), $this->payload()); + $response = HTTP::post($this->endPoint, $this->headers(), $this->payload()); return new VectoryLinkResponse($response); } - protected function payload(): array + protected function payload(): string { - return - [ - "SMSText" => $this->message, - "SMSReceiver" => $this->recipients, - "SMSSender" => $this->senderName, - 'SMSLang' => $this->lang, - 'UserName' => $this->username, - 'Password' => $this->password - ]; + return http_build_query([ + "SMSText" => $this->message, + "SMSReceiver" => $this->recipients, + "SMSSender" => $this->senderName, + 'SMSLang' => $this->lang, + 'UserName' => $this->username, + 'Password' => $this->password + ]); } protected function headers(): array { return [ - 'Content-Type' => 'text/xml; charset=utf-8', - 'Content-Length' => 0 + 'Content-Type' => 'application/x-www-form-urlencoded' ]; } } From 0bd37c564cac99206cce51dac3eba6cb50c2d62a Mon Sep 17 00:00:00 2001 From: Mostafa Tarek <109668729+Mostafa7000@users.noreply.github.com> Date: Thu, 8 Aug 2024 13:16:03 +0300 Subject: [PATCH 3/3] Update ConfigRepository.php add missing return type --- src/Support/ConfigRepository.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Support/ConfigRepository.php b/src/Support/ConfigRepository.php index 403db56..f4ded0e 100644 --- a/src/Support/ConfigRepository.php +++ b/src/Support/ConfigRepository.php @@ -79,7 +79,7 @@ public function offsetExists($offset): bool return $this->has($offset); } - public function offsetGet($offset) + public function offsetGet($offset): mixed { return $this->get($offset); }