File tree 1 file changed +9
-2
lines changed
src/Symfony/Component/Notifier/Bridge/LightSms
1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change 11
11
12
12
namespace Symfony \Component \Notifier \Bridge \LightSms ;
13
13
14
+ use Symfony \Component \HttpFoundation \Response ;
14
15
use Symfony \Component \Notifier \Exception \TransportException ;
15
16
use Symfony \Component \Notifier \Exception \UnsupportedMessageTypeException ;
16
17
use Symfony \Component \Notifier \Message \MessageInterface ;
@@ -99,9 +100,11 @@ protected function doSend(MessageInterface $message): SentMessage
99
100
throw new UnsupportedMessageTypeException (__CLASS__ , SmsMessage::class, $ message );
100
101
}
101
102
103
+ $ timestamp = time ();
104
+
102
105
$ signature = $ this ->generateSignature ([
103
106
'message ' => $ message ,
104
- 'timestamp ' => time () ,
107
+ 'timestamp ' => $ timestamp ,
105
108
]);
106
109
107
110
$ endpoint = sprintf (
@@ -112,11 +115,15 @@ protected function doSend(MessageInterface $message): SentMessage
112
115
$ this ->escapePhoneNumber ($ message ->getPhone ()),
113
116
$ this ->escapeSubject ($ message ->getSubject ()),
114
117
$ this ->phone ,
115
- time ()
118
+ $ timestamp
116
119
);
117
120
118
121
$ response = $ this ->client ->request ('GET ' , $ endpoint );
119
122
123
+ if (Response::HTTP_OK !== $ response ->getStatusCode ()) {
124
+ throw new TransportException ('Unable to send the SMS: ' , $ response );
125
+ }
126
+
120
127
$ content = $ response ->toArray (false );
121
128
122
129
if (isset ($ content ['error ' ])) {
You can’t perform that action at this time.
0 commit comments