HTTP Interface for SMS

Applicability: TGv2, TGv3

 

TG provides a HTTP interface to enable your applications to send messages over the internet. You can send SMS message using the HTTP interface. Parameters are specified in the URL.

Note: Limit your sending speed to 1 SMS per 10 seconds for 1 port when using this API.

Also, you could refer to the video guide: How To Use TG SMS HTTP API (Video)

Sending SMS format:
http://[IP]/cgi/WebCGI?1500101=account=[user]&password=[pass]&port=[port]&destination=[phone_number]&content=[MSG]

Sending USSD format:
http://[IP]/cgi/WebCGI?1500102=account=[user]&password=[pass]&port=[port]&content=[MSG]

Please check the following example SMS message from web.
If you want to send a message "Hello world!!" to phone number 15880270900 through TG GSM port 1.

The API settings are configured as the following picture shows:


As we can see, the [User] should be apiuser, and the [pass] should be password.


The URL format should be like this:
http://192.168.5.176/cgi/WebCGI?1500101=account=apiuser&password=password&port=1&destination=15880270900&content=Hello+world!!

For the content, it is better to convert it to URL Encode. 

You might find a tool in the Internet like this web tool: URL Encode Decode

Test

You can try to enter the whole URL in the browser address bar.

If the test result is good, you will get the response:

mceclip1.png

Request Sample

If you use the API via your own application. The HTTP method should be GET.

mceclip0.png

 

Have more questions? Submit a request

31 Comments

  • 0
    Avatar

    Hi You,

    I am a programmer. Now, I'm writing SMS function GT400 Neogate, but I do not know what is the value returned when I call the method"http://192.168.5.176/cgi/WebCGI?1500101=account=apiuser&password=password&port=1&destination=15880270900&content=Hello world!!".

    I hope to get feedback from you.

    Thanks you.

  • 0
    Avatar

    hi youu

    i wanna know how i can receive SMS  sent from the neogate device to an HTTP interface using the same things as u have done with sending the message here

    i hope to get feedback from you

    thank you

  • 1
    Avatar

    Hello @Trung Út Lê,

    If the SMS is sent successfully, you can will the receive the response like this:

    Response: Success
    Message: Commit successfully!

     

  • 1
    Avatar

    Hello halimalarhrafi1993,

    Currently, TG doesn't support read SMS via HTTP interface, hope you will know.

    Thanks.

  • 0
    Avatar

    Hi Pixy Xie,

    So, The response include two variables: response (value is Success and message (value is Commit successfuly) ?

    Looking forward to your response!

  • 0
    Avatar

    Hi,
    I must send sms from a remote server to local gateway. To perform the call I use jquery + ajax. Because it is a cross domain request I must use jsonp, but the gateway response is text/html, so I receive a syntax error from jquery. There is a way to fix it? Thanks.

  • 0
    Avatar

    Hello,

    I want to send massive sms from HTTP, this is possible?. my device is GT400 Neogate

  • 0
    Avatar

    dear all ;

    how can i send SMS to multiple Numbers

    what is the revived SMS Form ?

    what is the revived SMS sender name will appear ?  

    and what is the response in case there is failure in one of them 

    Edited by mahmoud elshennawy
  • 0
    Avatar

    Hi do you have example PHP code/framework to send SMS through Yeastar TGX00 I am  interested to understand Throttling, round Robin of GSM, need some way to read/store "Sucess Send of SMS" to the database on the sending app side, for example a way to handle a potential Queue of 1000 burst or high activity of SMS without dropping/loosing SMS transmissions
    For Round Robin of GSM modules is this Automatic and handled by the Yeastar TG?

    Some PHP Examples would be useful, thank you
     

  • 0
    Avatar

    Hello!

    how do I get the response to my application?

  • 0
    Avatar

    Hi. I make programm in JAVA for my needs. I can send and get SMS. But I understand, how i can connect to database for look all my sms. Help. Yeastas TG100. Sorry for my english.

  • 0
    Avatar

    Is it possible to send "+" before country code in destination filed?

  • 0
    Avatar

    Dear
    When I load the content of the message I wish to send, the space between the words replaces it with the + sign.
    How could I solve the problem?
    Grateful

  • 0
    Avatar

    USE URL ENCODE @Konstantin @Contacto

  • 0
    Avatar
    Response: Error
    Message: Authentication failed

    does it support in t400?

  • 0
    Avatar

    Hi,

    How can I end an ussd session using http interface after initiating a ussd session ?
    i have Yeastar tg400 model.

    thanks.

  • 0
    Avatar

    Hi,

    I have TG800 here. How can I access the Web GUI of the device?
    I have tried accessing using the default IP address (192.168.5.150) provided in the user's manual but didn't have any luck accessing it.
    Please someone help me.

    Thank you.

  • 0
    Avatar

    @louieje,you can advanced ip scanner to know the exact ip address or you do a manual reset.
    @Garry Hill,were you able to use the php code to store the status of the Sms sent (delivered or undelivered)? Were you able to get the php syntax to send the SMS?

  • 0
    Avatar

    onyegbado collins uc
    Yes
    it turned out to be not so hard to do in PHP
    establish your Gateway IP and Port, and set the Params your Yeastar should send a SMS

    Here is some code that worked for me (note +61 for Australia you can expand on that of course) it will send a test SMS, its mostly the same code I incorporated into my Application it will round robin the ports I have a 4 Channel Yeastar
    Hope it helps

    <!DOCTYPE html>
    <html>
    <head>
    <meta charset="UTF-8">
    <title>SMS Test</title>
    </head>
    <body>

    <?php
    $debug = 'on';
    $smskey = '12345';
    $mobile = '041234567';
    $SMS_gateway_account = 'username';
    $SMS_gateway_password = 'password';
    $SMS_leader = 'Use ';
    $SMS_trailer = ' for SMS validation';
    $SMS_message = $SMS_leader . $smskey . $SMS_trailer;
    $SMS_channel_count = '4';
    $SMS_gateway = '123.123.123.123';
    $SMS_port = '1111';
    $SMS_destination = 61 . substr($mobile, -9);
    // Starting Assumptions
    $SMS_success = 'NO';
    // Produce an array with unique random SMS ports in the channel count range starting at 1
    $random_port_array = range(1, $SMS_channel_count);
    shuffle($random_port_array);
    foreach($random_port_array as $channel)
    {
    ;
    $ch = curl_init();
    $SMS_gateway_password_encoded = curl_escape($ch, $SMS_gateway_password);
    $SMS_message_encoded = curl_escape($ch, $SMS_message);
    $transmission = "http://" . $SMS_gateway . ":" . $SMS_port . "/cgi/WebCGI?1500101=account=" . $SMS_gateway_account . "&password=" . $SMS_gateway_password_encoded . "&port=" . $channel . "&destination=" . $SMS_destination . "&content=" . $SMS_message_encoded;
    curl_setopt($ch, CURLOPT_URL, $transmission);
    if ($debug == 'on') { echo '<hr>' . $transmission . '<hr>'; }
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    $SMS_result = curl_exec($ch);
    if ($debug == 'on') { echo $SMS_result . '<hr>'; }
    if ((strpos($SMS_result, 'Response: Success') !== false) && ((strpos($SMS_result, 'Message: Commit successfully!') !== false)))
    {
    $SMS_success = 'YES';
    }
    else
    {
    $SMS_success = 'NO';
    }
    curl_close($ch);
    if ($SMS_success == 'YES')
    {
    echo '<h1 align="center">SMS SENT</h1>';
    break;
    }
    else
    {
    echo '<h1 align="center">SMS FAIL</h1>';
    }
    }
    ?>
    </body>
    </html>

    Edited by Garry Hill
  • 0
    Avatar

    Hello Gary Hiill,

    thanks for the swift response.Its well explanatory.

    However, i didnt see the plus sign before the 61

    $SMS_destination = 61 . substr($mobile, -9);

    something like :

    $SMS_destination = +61 . substr($mobile, -9);

  • 0
    Avatar

    because it cant dial like "+" I guess,

    my application required Australian Only phone numbers, you can probably leave like that out and the Telco/Provider will default to your country :-)

     

  • 0
    Avatar

    So what you are basically doing is Curling this below where [IP] is your Gateway IP (and port if you changed it)

    (From the Gateway Release notes)

    http://[IP]/cgi/WebCGI?1500101=account=[user]&password=[pass]&port=[port]&destination=351[phone_number]&content=[MSG]

    that crazy 1500101 IS important :-)

    and Destination, is that Country Code? I forgot, give it a try

    So perhaps like 61 (or your Country Code) is important
    this is Curl, so really its not just PHP all you are doing is using PHP to send the right type of curl

    Edited by Garry Hill
  • 0
    Avatar

    You are right.I can send the sms without the plus sign( within my country).

    Thanks. I will give it a try

  • 0
    Avatar

    Hey, Garry can you send sms in parallel from each port (sending sms to a different number from each channel at the same time)?

    Also how many messages per day, week, month where you handling in your app? I want to integrate an sms service into an app  Im building but i reckon i will send around 15000 mesagges per month. I am not sure if the TG400 will be able to handle that amount of meesagges or do you recommend another device.

     

    Regards

     

    David

    Edited by David Rodriguez
  • 0
    Avatar

    Hi I am new in yeastar and was able to purchase a tg400 model. I was able to create php app that can send message. My problem was is there API to get the received sms messages? 

  • 0
    Avatar

    @Gray Hill,is it possible to enter the sender id in the url ?

    $sender = 'ict';

    http://[IP]/cgi/WebCGI?1500101=account=[user]&password=[pass]&port=[port]&from=$sender&destination=351[phone_number]&content=[MSG]

  • 0
    Avatar

    See
    https://support.yeastar.com/hc/en-us/articles/217393078-HTTP-Interface-for-SMS

    Sending SMS format:
    http://[IP]/cgi/WebCGI?1500101=account=[user]&password=[pass]&port=[port]&destination=[phone_number]&content=[MSG]

    So No I dont beleive so,
    then perhaps I would try encode it as part of the Message, so you could perhaps dream up a Delimeter Char if you wanted to Extract a sender ID programatically 
    like &content=Message#SenderID

    Good Luck




  • 0
    Avatar

    how can you exit a ussd session using this method?

  • 0
    Avatar

    Hi,

    I am the happy owner of an SMS gateway YS-TG100.

    Can anyone share the PHP code for sending SMS from the website?

     

    Many Thanks

  • 0
    Avatar

    Hellos,
    Nice meeting you today

Please sign in to leave a comment.