Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
b075c0e
* LightSms notifier
Mar 28, 2021
f2ba226
* LightSmsTransport.php - bug fix
Mar 28, 2021
be8f994
* LightSmsTransport.php - return type
Mar 28, 2021
167f325
* LightSmsTransport.php - logic error
Mar 28, 2021
6792535
* composer.json - requirements bug fix
Mar 28, 2021
2f65b92
* LightSmsTransport.php - Coding Standard
Mar 28, 2021
15686c0
* LightSmsTransport.php - Coding Standard
Mar 28, 2021
a0fae7d
* tests
Mar 28, 2021
d1ccd46
* Attached file changes which are required to run the lightsms notifier
Mar 28, 2021
ce41756
* notifier_transports.php - Coding Standard
Mar 28, 2021
728a3e2
* Transport.php - missing use
Mar 28, 2021
4a11b94
* github account author
Mar 28, 2021
febff46
Update src/Symfony/Component/Notifier/Bridge/LightSms/LICENSE
StaffNowa Mar 28, 2021
9e1809e
* small changes
Mar 28, 2021
3cbbc85
* HOST split into two parts
Mar 28, 2021
5e54dfe
* LightSmsTransport.php - quick fix for private constant.
Mar 28, 2021
9f89014
Update src/Symfony/Component/Notifier/Bridge/LightSms/README.md
StaffNowa Mar 28, 2021
c02dbbd
Update src/Symfony/Component/Notifier/Bridge/LightSms/README.md
StaffNowa Mar 28, 2021
b2e4638
Update src/Symfony/Component/Notifier/Bridge/LightSms/LightSmsTranspo…
StaffNowa Mar 28, 2021
49b4780
Update src/Symfony/Component/Notifier/Bridge/LightSms/LightSmsTranspo…
StaffNowa Mar 28, 2021
b0891be
Update src/Symfony/Component/Notifier/Bridge/LightSms/LightSmsTranspo…
StaffNowa Mar 28, 2021
1b073c2
Update src/Symfony/Component/Notifier/Bridge/LightSms/LightSmsTranspo…
StaffNowa Mar 28, 2021
e0a68bd
Update src/Symfony/Component/Notifier/Bridge/LightSms/LightSmsTranspo…
StaffNowa Mar 28, 2021
3d0d79c
Update src/Symfony/Component/Notifier/Bridge/LightSms/Tests/LightSmsT…
StaffNowa Mar 28, 2021
0e41bc9
Update src/Symfony/Component/Notifier/Bridge/LightSms/Tests/LightSmsT…
StaffNowa Mar 28, 2021
079406e
Update src/Symfony/Component/Notifier/Bridge/LightSms/LightSmsTranspo…
StaffNowa Mar 28, 2021
7b51e0d
Update src/Symfony/Component/Notifier/Bridge/LightSms/LightSmsTranspo…
StaffNowa Mar 28, 2021
2e0e1d7
Update README.md
StaffNowa Mar 28, 2021
66c34ba
Update README.md
StaffNowa Mar 28, 2021
8620e82
* LightSmsTransport.php - move timestamp
Mar 29, 2021
5d2e692
* LightSmsTransport.php - escape phone number
Mar 29, 2021
fc13bb2
* LightSmsTransport.php - changed login for validation (the same like…
Mar 29, 2021
b0e64b9
* LightSmsTransport.php - not ok throw exception
Mar 29, 2021
e20ef1e
* LightSmsTransport.php - change + to 00
Mar 29, 2021
7f13dbf
* sender changed to from
Mar 29, 2021
f16b4d2
* phone changed to from
Mar 29, 2021
7180c1f
Update LightSmsTransport.php
StaffNowa Mar 29, 2021
08b0729
Update LightSmsTransport.php
StaffNowa Mar 29, 2021
80ef5ba
* LightSmsTransport.php - Unable to send the SMS: Closing direction t…
Mar 30, 2021
08235e5
* LightSmsTransport.php - bug fix
Mar 30, 2021
23a446a
* LightSmsTransport.php - issue with Symfony\Component\Notifier\Bridg…
Mar 30, 2021
265f776
* LightSmsTransport.php - issue with Symfony\Component\Notifier\Bridg…
Mar 30, 2021
b9f9ff8
* LightSmsTransport.php - tests fail
Mar 30, 2021
58ac708
* LightSmsTransport.php - return back www (without will not work). No…
Mar 30, 2021
1b59a7d
* LightSmsTransport.php - string param
Apr 1, 2021
1c993b7
* ERROR_CODES -> int
Apr 1, 2021
1ff97e4
* LightSmsTransport.php - build signature and use http_build_query, t…
Apr 1, 2021
83d2598
* Coding Standard patch
Apr 1, 2021
a197dee
* LightSmsTransport.php - better to remove if we do not have it?
Apr 1, 2021
95e82f6
Update LightSmsTransport.php
StaffNowa Apr 2, 2021
178d9c2
* pull request #40696
StaffNowa Apr 4, 2021
9a832ef
* LightSmsTransport.php - via mistake removed www which return (Closi…
StaffNowa Apr 4, 2021
0d7488b
* type cast. On success lightsms return error code like string. On er…
StaffNowa Apr 4, 2021
9b2e2d0
* type cast. On success lightsms return error code like string. On er…
StaffNowa Apr 4, 2021
bea5256
* type cast. On success lightsms return error code like string. On er…
StaffNowa Apr 4, 2021
21e972a
* coding standard
StaffNowa Apr 4, 2021
4213564
* composer.json - fix Fabien comment from another pull request #40646
StaffNowa Apr 5, 2021
2a9ac2d
* LightSmsTransport.php - fix
Apr 6, 2021
026dcd9
* LightSmsTransport.php - isset
Apr 6, 2021
f1f83b9
* LightSmsTransport.php - use query string parameters
Apr 6, 2021
68a12fa
* fix tests
Apr 6, 2021
37c665e
* LightSmsTransport.php - make fabbot happy
Apr 6, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
* LightSmsTransport.php - quick fix for private constant.
  • Loading branch information
Vasilij Dusko authored and Vasilij Dusko | CREATION committed Mar 29, 2021
commit 5e54dfe475cc62a80a7c0d6ec601c4f03c869128
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,8 @@ final class LightSmsTransport extends AbstractTransport
private $login;
private $password;
private $phone;
/**
* @var MessageInterface
*/
private $message;

private $errorCodes = [
private const ERROR_CODES = [
'000' => 'Service unavailable',
'1' => 'Signature not specified',
'2' => 'Login not specified',
Expand Down Expand Up @@ -103,9 +99,7 @@ protected function doSend(MessageInterface $message): SentMessage
throw new UnsupportedMessageTypeException(__CLASS__, SmsMessage::class, $message);
}

$this->message = $message;

$signature = $this->generateSignature();
$signature = $this->generateSignature($message);

$endpoint = sprintf(
'https://%s/external/get/send.php?login=%s&signature=%s&phone=%s&text=%s&sender=%s&timestamp=%s',
Expand All @@ -123,12 +117,12 @@ protected function doSend(MessageInterface $message): SentMessage
$content = $response->toArray(false);

if (isset($content['error'])) {
throw new TransportException('Unable to send the SMS: '.$this->errorCodes[$content['error']], $response);
throw new TransportException('Unable to send the SMS: '.self::ERROR_CODES[$content['error']], $response);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what if the error code is not define in ERROR_CODES?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It will throw undefined error 🙄 how than validate it 🤔 yes possible they can send another error code or change documentation changes. Maybe put if not exists like as unknown error (add new one number)

Copy link
Contributor Author

@StaffNowa StaffNowa Apr 3, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Success json

{"37061122333":{"error":"0", "id_sms":"4092112510348380960001", "cost":"0.5", "count_sms":"1"}}

Copy link
Contributor Author

@StaffNowa StaffNowa Apr 3, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Failure json

{"error":6}

Copy link
Contributor Author

@StaffNowa StaffNowa Apr 3, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Their uses in different cases different response. How we can manage than 🙄 use (int) before error 🙄

Response for all queries HTTP OK (200)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added (int) before return error. On success their return like string. On error their return integer.

}

$phone = preg_replace("/[^\d]/", '', $message->getPhone());
if (32 == $content[$phone]['error']) {
throw new TransportException('Unable to send the SMS: '.$this->errorCodes[$content['error']], $response);
throw new TransportException('Unable to send the SMS: '.self::ERROR_CODES[$content['error']], $response);
}

if (0 == $content[$phone]['error']) {
Expand All @@ -139,14 +133,14 @@ protected function doSend(MessageInterface $message): SentMessage
return $sentMessage;
}

private function generateSignature(): string
private function generateSignature(SmsMessage $message): string
{
$params = [
'timestamp' => time(),
'login' => $this->login,
'phone' => str_replace('+', '', $this->message->getPhone()),
'phone' => str_replace('+', '', $message->getPhone()),
'sender' => $this->phone,
'text' => $this->message->getSubject(),
'text' => $message->getSubject(),
];

ksort($params);
Expand Down