Back to Home

Sending SMS from a PHP script or command line

If you have a need to send SMS messages from the console or PHP program · then you can use the following ...

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 ',' Hello ! ')));


    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 - recipient number, accepted as 79255005050, you must specify the country code at the beginning of the number. If 8 is indicated, it will be considered that the recipient is located on the territory of the Russian Federation or neighboring states using code 7.
    text - message text, in UTF-8 format.
    from (optional) - signature of the sender, must first be moderated . If not specified, then your mobile phone number will be substituted.

    Answer Options:


    100 Message received. The second line will indicate the message identifier.
    200 Incorrect api_id
    201 There is no money in the personal account
    202 The recipient is incorrectly indicated
    203 There is no message text
    204 The sender's name is not agreed with the administration
    205 The message is too long (exceeds 5 SMS)
    211 The method was not found
    220 The service is temporarily unavailable, try a little later.

    Status Check:


    You must use the sms / status method

    And now for the surprise:


    We respect you and offer the lowest price on the market.
    The cost of sending one message is 50 kopecks
    SMS Newsletter





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





    Read Next