Method for sending a single SMS message to one recipient.
GETPOST https://semysms.net/api/3/sms.php
Parameters
-
token
required
- secret API access key
-
device
required
- device code from the list of your connected devices. One or several separated by commas. The value active means that all active devices of the account will be used. If several devices are given, or the value is active, the service distributes new SMS between them in turn
-
phone
required
- recipient phone number in international format with the country code
-
msg
required
- message text, up to 1000 characters
-
priority
- sending priority: the bigger the number, the higher the priority (integer from 0 to 1000000)
-
add_contact
- create a contact in the contact list (0 or empty - no, 1 - create)
-
name
- contact name for creating the number in the contact list
-
surname
- contact surname for creating the number in the contact list
-
add_plus
- forcibly adds a + character to the phone number (0 or empty - not used, 1 - add +)
GET request example
If one device:
https://semysms.net/api/3/sms.php?token=2d9d148edeb50768c22dc6d96f85d60b&device=1&phone=%2B12025550123&msg=Message
If several devices:
https://semysms.net/api/3/sms.php?token=2d9d148edeb50768c22dc6d96f85d60b&device=1,15,25&phone=%2B12025550123&msg=Message
POST request example
<?php
$url = 'https://semysms.net/api/3/sms.php'; // URL for sending SMS
$phone = '+12025550123'; // phone number
$msg = 'Message'; // message
$device = '1'; // your device code
$token = '2d9d148edeb50768c22dc6d96f85d60b'; // your token (secret)
$data = array(
'phone' => $phone,
'msg' => $msg,
'device' => $device,
'token' => $token
);
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$output = curl_exec($curl);
curl_close($curl);
echo $output;
Response example
{"code":"0","id":1201158}
Sending several messages
Method for sending several SMS messages in one request. Parameters are passed in the JSON body of a POST request, in the data array.
POST https://semysms.net/api/3/sms_more.php
Parameters
-
token
required
- secret API access key
-
device
required
- device code from the list of your connected devices
-
phone
required
- recipient phone number in international format with the country code
-
msg
required
- message text, up to 1000 characters
-
my_id
- SMS code from your own system: it is returned in the response together with the SemySMS code
-
priority
- sending priority: the bigger the number, the higher the priority (integer from 0 to 1000000)
POST request example
<?php
$url = 'https://semysms.net/api/3/sms_more.php'; // URL for sending SMS
$device = '1'; // your device code
$token = '2d9d148edeb50768c22dc6d96f85d60b'; // your token (secret)
$params = array('token' => $token);
for ($i = 1; $i <= $max_count; $i++) { // fill the array with numbers, messages and device codes
$params['data'][] = array(
'my_id' => $my_id, // code from your own system, returned together with the SemySMS code
'device' => $device,
'phone' => $phone,
'msg' => $msg
);
}
$params = json_encode($params);
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $params);
$result = curl_exec($curl);
curl_close($curl);
echo $result;
Response example
{
"code": "0",
"data": [
{ "my_id": "...", "id": 1201158 } // the value is present if it was set in the request
]
}