SOAP interface


SMSfarm implements a SOAP interface, which is a standard for system integration for all platform(s). You can integrate SOAP interface on popular platforms like PHP, JAVA, Python, Perl, C++, .NET, C#, etc. All you have to do is to find a SOAP client library for your platform and write few lines of code to implement our API.

Security keys
You need two security keys to be able to use our API. Integration ID and Integration code , which is used for signing your requests. You can find these keys in your profile. You can also simply copy examples below, which already include your security keys, if you are already logged in.

Signing algorithm
We use simple yet powerful algorithm for message signing, so your code can be never compromised. You can see the algorithm in examples below


PHP Example

Here is a simple PHP example how to send a message

            <?php
                // http://www.php.net/manual/en/class.soapclient.php
                // Uncomment following line in /etc/php.ini
                // extension=soap.so

                try {
                    // one or more recipients separated by comma
                    $recipient = "+1 800 123 4567";

                    $code = "sample-code";
                    $signature = substr(md5($code.$recipient), 10, 11);
                    $sender = "your ALIAS or PHONE NUMBER";

                    $values = array(
                        "integration_id" => "sample-id",
                        "sender" => $sender,
                        "recipient" => $recipient,
                        "message" => "PHP SOAP test using smsfarm.sk API",
                        "signature" => $signature
                        );

                    $client = new SoapClient("https://app.smsfarm.sk/api/?wsdl");

                    $request_id = $client->SendMessage($values);
                    print_r($request_id);

                    // request_id is a unique number, which can be used to obtain delivery status
                    // wait 1-3 minutes to receive delivery status
                    // it take few minutes for message to be delivered to cell phone

                } catch (Exception $e) {
                    print_r($e->getMessage());
                }
            ?>
            
Delivery status

In order to receive single message delivery status, use GetMessageStatusand add request_id and number parameter.

            <?php
                try {
                    $recipient = "+1 800 123 4567";
                    $code = "sample-code";
                    $request_id = '12345'; // output from previous example

                    // sign request_id parameter
                    $signature = substr(md5($code.$request_id), 10, 11);

                    $values = array(
                        "integration_id" => "${source.integration_id}",
                        "request_id" => $request_id,
                        "number" => $recipient,
                        "signature" => $signature
                        );

                    $client = new SoapClient("https://app.smsfarm.sk/api/?wsdl");

                    $delivery_status = $client->GetMessageStatus($values);
                    print_r($delivery_status);

                    // Delivery statuses:
                    // QUEUED - message is queued and will be sent shortly
                    // SENDING - message is being sent right now
                    // SENT - message was sent successfully
                    // DELIVERED - message was delivered to cell phone
                    // INVALID-NUMBER - no valid number was supplied in request
                    // MESSAGE-CANCELLED - message was cancelled by user
                    // MESSAGE-EXPIRED - delivery time expired
                    // MESSAGE-UNDELIVERED - message not delivered for unknown reason
                    // SENT-DELIVERY-UNKNOWN - message was sent, but delivery status is unknown
                    // COUNTRY-FORBIDDEN - destination country is forbidden, contact us
                    // SENDING-FAILED - uknown error while sending

                } catch (Exception $e) {
                    print_r($e->getMessage());
                }
            ?>
            
Scheduled message

To schedule a message just use SendScheduledMessageand add a send_time parameter as follows.

            <?php
                try {
                    // one or more recipients separated by comma
                    $recipient = "+1 800 123 4567";

                    $code = "sample-code";
                    $signature = substr(md5($code.$recipient), 10, 11);
                    $sender = "your ALIAS or PHONE NUMBER";

                    $values = array(
                        "integration_id" => "${source.integration_id}",
                        "sender" => $sender,
                        "recipient" => $recipient,
                        "send_time" => date("Y-m-d H:i"),
                        "message" => "PHP SOAP test using smsfarm.sk API",
                        "signature" => $signature
                        );

                    $client = new SoapClient("https://app.smsfarm.sk/api/?wsdl");

                    $result = $client->SendScheduledMessage($values);
                    print_r($result);

                } catch (Exception $e) {
                    print_r($e->getMessage());
                }
            ?>
            

To cancel previously scheduled message, that hasn't been sent yet, use CancelScheduledMessage and add request_id parameter

            <?php
                try {
                    $code = "sample-code";
                    $request_id = '12345'; // output from previous example

                    // sign request_id parameter
                    $signature = substr(md5($code.$request_id), 10, 11);

                    $values = array(
                        "integration_id" => "${source.integration_id}",
                        "request_id" => $request_id,
                        "signature" => $signature
                        );

                    $client = new SoapClient("https://app.smsfarm.sk/api/?wsdl");

                    $result = $client->CancelScheduledMessage($values);
                    print_r($result);

                } catch (Exception $e) {
                    print_r($e->getMessage());
                }
            ?>
            
Remaining credit

You can use GetCreditAmount procedure to get your remaining credit. In this case, you are singing your integration ID

            <?php
                try {
                    $recipient = "+1 800 123 4567";
                    $code = "sample-code";

                    $signature = substr(md5($code.$integration_id), 10, 11);

                    $values = array(
                        "integration_id" => $integration_id,
                        "signature" => $signature
                        );

                    $client = new SoapClient("https://app.smsfarm.sk/api/?wsdl");

                    $result = $client->GetCreditAmount($values);
                    print_r($result);

                } catch (Exception $e) {
                    print_r($e->getMessage());
                }
            ?>