@@ -33,46 +33,46 @@ final class LightSmsTransport extends AbstractTransport
33
33
private $ from ;
34
34
35
35
private const ERROR_CODES = [
36
- ' 000 ' => 'Service unavailable ' ,
37
- ' 1 ' => 'Missing Signature ' ,
38
- ' 2 ' => 'Login not specified ' ,
39
- ' 3 ' => 'Text not specified ' ,
40
- ' 4 ' => 'Phone number not specified ' ,
41
- ' 5 ' => 'Sender not specified ' ,
42
- ' 6 ' => 'Invalid signature ' ,
43
- ' 7 ' => 'Invalid login ' ,
44
- ' 8 ' => 'Invalid sender name ' ,
45
- ' 9 ' => 'Sender name not registered ' ,
46
- ' 10 ' => 'Sender name not approved ' ,
47
- ' 11 ' => 'There are forbidden words in the text ' ,
48
- ' 12 ' => 'Error in SMS sending ' ,
49
- ' 13 ' => 'Phone number is in the blackist. SMS sending to this number is forbidden. ' ,
50
- ' 14 ' => 'There are more than 50 numbers in the request ' ,
51
- ' 15 ' => 'List not specified ' ,
52
- ' 16 ' => 'Invalid phone number ' ,
53
- ' 17 ' => 'SMS ID not specified ' ,
54
- ' 18 ' => 'Status not obtained ' ,
55
- ' 19 ' => 'Empty response ' ,
56
- ' 20 ' => 'The number already exists ' ,
57
- ' 21 ' => 'No name ' ,
58
- ' 22 ' => 'Template already exists ' ,
59
- ' 23 ' => 'Missing Month (Format: YYYY-MM) ' ,
60
- ' 24 ' => 'Timestamp not specified ' ,
61
- ' 25 ' => 'Error in access to the list ' ,
62
- ' 26 ' => 'There are no numbers in the list ' ,
63
- ' 27 ' => 'No valid numbers ' ,
64
- ' 28 ' => 'Missing start date (Format: YYYY-MM-DD) ' ,
65
- ' 29 ' => 'Missing end date (Format: YYYY-MM-DD) ' ,
66
- ' 30 ' => 'No date (format: YYYY-MM-DD) ' ,
67
- ' 31 ' => 'Closing direction to the user ' ,
68
- ' 32 ' => 'Not enough money ' ,
69
- ' 33 ' => 'Missing phone number ' ,
70
- ' 34 ' => 'Phone is in stop list ' ,
71
- ' 35 ' => 'Not enough money ' ,
72
- ' 36 ' => 'Can not obtain information about phone ' ,
73
- ' 37 ' => 'Base Id is not set ' ,
74
- ' 38 ' => 'Phone number already exists in this database ' ,
75
- ' 39 ' => 'Phone number does not exist in this database ' ,
36
+ 000 => 'Service unavailable ' ,
37
+ 1 => 'Missing Signature ' ,
38
+ 2 => 'Login not specified ' ,
39
+ 3 => 'Text not specified ' ,
40
+ 4 => 'Phone number not specified ' ,
41
+ 5 => 'Sender not specified ' ,
42
+ 6 => 'Invalid signature ' ,
43
+ 7 => 'Invalid login ' ,
44
+ 8 => 'Invalid sender name ' ,
45
+ 9 => 'Sender name not registered ' ,
46
+ 10 => 'Sender name not approved ' ,
47
+ 11 => 'There are forbidden words in the text ' ,
48
+ 12 => 'Error in SMS sending ' ,
49
+ 13 => 'Phone number is in the blackist. SMS sending to this number is forbidden. ' ,
50
+ 14 => 'There are more than 50 numbers in the request ' ,
51
+ 15 => 'List not specified ' ,
52
+ 16 => 'Invalid phone number ' ,
53
+ 17 => 'SMS ID not specified ' ,
54
+ 18 => 'Status not obtained ' ,
55
+ 19 => 'Empty response ' ,
56
+ 20 => 'The number already exists ' ,
57
+ 21 => 'No name ' ,
58
+ 22 => 'Template already exists ' ,
59
+ 23 => 'Missing Month (Format: YYYY-MM) ' ,
60
+ 24 => 'Timestamp not specified ' ,
61
+ 25 => 'Error in access to the list ' ,
62
+ 26 => 'There are no numbers in the list ' ,
63
+ 27 => 'No valid numbers ' ,
64
+ 28 => 'Missing start date (Format: YYYY-MM-DD) ' ,
65
+ 29 => 'Missing end date (Format: YYYY-MM-DD) ' ,
66
+ 30 => 'No date (format: YYYY-MM-DD) ' ,
67
+ 31 => 'Closing direction to the user ' ,
68
+ 32 => 'Not enough money ' ,
69
+ 33 => 'Missing phone number ' ,
70
+ 34 => 'Phone is in stop list ' ,
71
+ 35 => 'Not enough money ' ,
72
+ 36 => 'Can not obtain information about phone ' ,
73
+ 37 => 'Base Id is not set ' ,
74
+ 38 => 'Phone number already exists in this database ' ,
75
+ 39 => 'Phone number does not exist in this database ' ,
76
76
];
77
77
78
78
public function __construct (string $ login , string $ password , string $ from , HttpClientInterface $ client = null , EventDispatcherInterface $ dispatcher = null )
@@ -105,7 +105,7 @@ protected function doSend(MessageInterface $message): SentMessage
105
105
$ signature = $ this ->generateSignature ($ message , $ timestamp );
106
106
107
107
$ endpoint = sprintf (
108
- 'https://www. %s/external/get/send.php?login=%s&signature=%s&phone=%s&text=%s&sender=%s×tamp=%s ' ,
108
+ 'https://%s/external/get/send.php?login=%s&signature=%s&phone=%s&text=%s&sender=%s×tamp=%s ' ,
109
109
$ this ->getEndpoint (),
110
110
$ this ->login ,
111
111
$ signature ,
@@ -123,7 +123,8 @@ protected function doSend(MessageInterface $message): SentMessage
123
123
124
124
$ content = $ response ->toArray (false );
125
125
126
- if (isset ($ content ['' ])) {
126
+ // it happens if the host without www
127
+ if (isset ($ content ['' ]) && isset ($ content ['' ]['error ' ])) {
127
128
throw new TransportException ('Unable to send the SMS: ' .self ::ERROR_CODES [$ content ['' ]['error ' ]], $ response );
128
129
}
129
130
0 commit comments