Skip to main content

Tutorials

Easy to understand tutorials made for you, by us.

SIGN UP FOR FREE

How to send SMS messages

With the Silverstreet API it is really simple the send SMS, including Unicode and long SMS, to one or more mobile phone numbers. In this tutorial we will explain how to do it.

To send an SMS you need to know at least 3 things:

  1. The recipient, so the number of the person you want the SMS to.
  2. The body, so the message you want to send.
  3. The sender, so what the recipients sees who sent the SMS.

Recipient

The recipient of the SMS the mobile number you will send the SMS to. The recipient must always be in international format, without leading `+` or `00`. In international format means that you have add the country prefix to the local number. For example, if the country prefix is `+31` and the local number is `0612345678`, you remove the leading `0` of the local number and prepend the country prefix. As you then have to strip the leading `+` or `00`, the result will be `31612345678`.

Body

The body of the SMS is the actual text you want to send. When sending an SMS you have to consider the maximum length of the SMS. The maximum length depends on the character set you use. For 7-bit GSM characters the maximum length is 160 characters and for Unicode the maximum length is 70 characters. Sometimes you want to send longer SMS to your customers. In the tutorial ‘How to send a concatenated/long SMS‘ we will explain how you can do that.

The 7-bit GSM character set is a limited set of characters you can send. The following characters are available in this character set:

@£$¥èéùìòÇØøÅåΔ_ΦΓΛΩΠΨΣΘΞ^{}[~]|€ÆæßÉ!"#¤%&'()*+,-./0123456789:;<=>?¡
ABCDEFGHIJKLMNOPQRSTUVWXYZÄÖÑܧ¿abcdefghijklmnopqrstuvwxyzäöñüà

When you want to send other characters, e.g. Chinese, you have to use Unicode. Our API will simply detect if the body is 7-bit GSM or not, so you don’t have to do anything for that.

Sender

The sender of an SMS is where the SMS comes from. So when you send an SMS with your mobile phone, the receiver will see your number. With our API you can set your own sender but also an alphanumeric sender, for example your company name. In our tutorial ‘What is the sender ID of an SMS‘ we will explain more about the sender.

Other settings

Besides the recipient, body and sender, there are other settings you can do for an SMS. Checkout our API specification for more information on those settings.

Example sending an SMS

So how can you send an SMS with our API? Here an example:


$body = 'This is the body of the SMS.';
$recipient = '316987654321';
$sender = '316123456789';$sms = $client->createSms($body, $recipient, $sender);
$sms->sendSimple();
echo $sms->getMessageId();

Delivery result

When you have submitted the SMS, you can get the status of the SMS. To get the status of an SMS, there a few options. You can simply get the status of the SMS by the id when submitting the SMS, poll for delivery reports or receive a HTTP call from our system. More information on that you can find in our API documentation. For this tutorial we will simply get the status based on the id.


$result = $client->getSms($sms->getMessageId());

Example of the data returned by the API:


{
"applicationTag": "test",
"body": "Body of the SMS",
"callbackUrl": null,
"createdDateTime": "2016-11-29T11:20:22+00:00",
"dcs": null,
"messageId": "eu-01-1.18667.sms583d64765f6b28.36322430",
"networkCode": 12345,
"pid": null,
"reasonCode": 0,
"recipient": "1234567890",
"resultType": 0,
"salesPrice": 0.001,
"salesPriceCurrencyCode": "eur",
"scheduledDelivery": null,
"sender": "Hello world",
"senderNpi": 0,
"senderTon": 5,
"status": "delivered",
"statusCode": 1,
"tag": null,
"resultTimestamp": "2016-11-29T11:20:24+00:00",
"udh": null,
"validity": 259200,
"validUntilDateTime": "2016-12-02T11:20:22+00:00",
"_links": {
"self": {
"href": "https://api-eu-01.silverstreet.com/v1/sms/submit/eu-01-1.18667.sms583d64765f6b28.36322430"
}
}
}