📜 ⬆️ ⬇️

Sending SMS from a PHP script or command line

image
If you need to send SMS messages from the console or PHP program, then you can use the following commands:


Http:
http://sms.ru/sms/send?api_id=00000-0000-0000-000&to=79255005050&text=hello+world
Console (must install curl):
curl http://sms.ru/sms/send\?api_id=00000-0000-0000-000\&to=79255005050\&text=hello+world
PHP:
$ body = file_get_contents ('http://sms.ru/sms/send?api_id=00000-0000-0000-000&to=7925500505&text='.urlencode (iconv (' windows-1251 ',' utf-8 ',' Hi ! ')));


Options:


api_id is your unique key. To get it, you need to register on sms.ru and go to the " Developers " section in the top menu.
to - the number of the recipient, taken in the form 79255005050, you must specify the country code at the beginning of the number. If an 8-ka is indicated, it will be assumed that the recipient is located in the territory of the Russian Federation or neighboring states using code 7.
text - the text of the message, in UTF-8 format.
from (optional) - the signature of the sender, must be moderated beforehand. If not specified, your mobile phone number will be substituted.
')

Answer options:


100 Message accepted for dispatch. The second line will contain the message identifier.
200 Wrong api_id
201 No funds on personal account
202 Invalid recipient
203 No text message
204 Sender name not agreed with administration
205 Message too long (exceeds 5 SMS)
211 Method not found
220 Service is temporarily unavailable, try a bit later.

Status check:


You must use the sms / status method

And now the surprise:


We respect you and provide the lowest price on the market.
The cost of sending a single message - 50 kopecks
SMS sending





update: the sms / status message status checking method is now available





Source: https://habr.com/ru/post/97977/


All Articles