26
26
*/
27
27
final class LightSmsTransport extends AbstractTransport
28
28
{
29
- protected const HOST = 'www. lightsms.com ' ;
29
+ protected const HOST = 'lightsms.com ' ;
30
30
31
31
private $ login ;
32
32
private $ password ;
@@ -75,11 +75,11 @@ final class LightSmsTransport extends AbstractTransport
75
75
'39 ' => 'Phone number does not exist in this database ' ,
76
76
];
77
77
78
- public function __construct (string $ login , string $ password , string $ phone , HttpClientInterface $ client = null , EventDispatcherInterface $ dispatcher = null )
78
+ public function __construct (string $ login , string $ password , string $ from , HttpClientInterface $ client = null , EventDispatcherInterface $ dispatcher = null )
79
79
{
80
80
$ this ->login = $ login ;
81
81
$ this ->password = $ password ;
82
- $ this ->phone = $ phone ;
82
+ $ this ->from = $ from ;
83
83
84
84
parent ::__construct ($ client , $ dispatcher );
85
85
}
@@ -102,19 +102,16 @@ protected function doSend(MessageInterface $message): SentMessage
102
102
103
103
$ timestamp = time ();
104
104
105
- $ signature = $ this ->generateSignature ([
106
- 'message ' => $ message ,
107
- 'timestamp ' => $ timestamp ,
108
- ]);
105
+ $ signature = $ this ->generateSignature ($ message , $ timestamp );
109
106
110
107
$ endpoint = sprintf (
111
- 'https://%s/external/get/send.php?login=%s&signature=%s&phone=%s&text=%s&sender=%s×tamp=%s ' ,
108
+ 'https://www. %s/external/get/send.php?login=%s&signature=%s&phone=%s&text=%s&sender=%s×tamp=%s ' ,
112
109
$ this ->getEndpoint (),
113
110
$ this ->login ,
114
111
$ signature ,
115
112
$ this ->escapePhoneNumber ($ message ->getPhone ()),
116
113
$ this ->escapeSubject ($ message ->getSubject ()),
117
- $ this ->phone ,
114
+ $ this ->from ,
118
115
$ timestamp
119
116
);
120
117
@@ -143,14 +140,14 @@ protected function doSend(MessageInterface $message): SentMessage
143
140
return $ sentMessage ;
144
141
}
145
142
146
- private function generateSignature (array $ params ): string
143
+ private function generateSignature (SmsMessage $ message , string $ timestamp ): string
147
144
{
148
145
$ params = [
149
- 'timestamp ' => $ params [ ' timestamp ' ] ,
146
+ 'timestamp ' => $ timestamp ,
150
147
'login ' => $ this ->login ,
151
- 'phone ' => $ this ->escapePhoneNumber ($ params [ ' message ' ] ->getPhone ()),
152
- 'sender ' => $ this ->phone ,
153
- 'text ' => $ this ->escapeSubject ($ params [ ' message ' ] ->getSubject ()),
148
+ 'phone ' => $ this ->escapePhoneNumber ($ message ->getPhone ()),
149
+ 'sender ' => $ this ->from ,
150
+ 'text ' => $ this ->escapeSubject ($ message ->getSubject ()),
154
151
];
155
152
156
153
ksort ($ params );
0 commit comments