Send/Schedule SMS to a Contact
Description
Send or Schedule a SMS to a specific contact. Accepts GET or POST requests.
URL
https://melotext.com/apis/smscontact/
Example Call: https://melotext.com/apis/smscontact/?apikey=APIKEY&from=FROMNUMBER&to=CONTACTNUMBER&message=MESSAGE
PHP Code Sample (cURL):
$url = 'https://melotext.com/apis/smscontact/';
$fields = array('apikey' => $api_key,
'from' => $from,
'to' => $to,
'message' => $message,
);
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($fields));
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/x-www-form-urlencoded'));
$result = curl_exec($ch);
return $result;
Parameters
Parameters | Required | Description |
---|---|---|
apikey | Required | The API key of your account. |
from | Required | The number you are sending from. Could be any SMS-enabled number in your account. |
to | Required | The contact number you are sending the message to. Example: 18159819712 |
message | Required | The message text you are sending. 1 credit is charged for each 160 character segment. NOTE: Messages containing non-GSM(unicode) characters will be charged 1 credit for each 70 character segment. |
alphasender | Optional | This is the alphanumeric sender ID you want to send the message from. Only certain countries can send from an alphanumeric sender id, which are included below: AUSTRALIA, AUSTRIA, DENMARK, ESTONIA, FINLAND, FRANCE, GERMANY, HONG KONG, IRELAND, ISRAEL, LITHUANIA, NETHERLANDS, NORWAY, POLAND, SPAIN, SWEDEN, SWITZERLAND, UNITED KINGDOM Alphanumeric SenderID requirements: Any combination of 1 to 11 letters(A-Z/a-z) and numbers(0-9). 1 letter and no more than 11 alphanumeric characters may be used. |
sendondate | Optional | If scheduling bulk SMS, this is the date/time message will be sent. If it's a recurring event, this is the 1st date/time in the series. Format: DD-MM-YYYY HH:MM |
recurring | Optional | Create recurring events. Set to 1 if you want to create a recurring event. |
repeat | Optional | Type of recurring event you want to schedule. Valid values are 'Daily', 'Weekly', 'Monthly', 'Yearly'. |
frequency | Optional | How often you want the recurring events to happen based on the Repeat parameter above. For example, if you pass in 'Daily' for repeat and '3' for Frequency, it will schedule the events every 3 days. Valid values are 1-30. |
enddate | Optional | End date you want the recurring events to end. For example, if you pass in a sendondate(start date) of Oct 10 at 6:30 and you want the last event to run on Nov 10, you must pass in an end date of Nov 10 at 6:30 so Nov 10 will be included as the last date. Format: DD-MM-YYYY HH:MM |
Return Values
Return Code | Description |
---|---|
0 | 0 is passed back on successful API call when scheduling bulk SMS. The group SMS ID will be passed back on successful API call when sending bulk SMS immediately. |
-1 | Invalid API key passed in. |
-2 | There was no 'from' number passed in. |
-3 | The 'from' number passed in doesn't exist in your account or isn't SMS-enabled. |
-4 | There was no message passed in to be sent. |
-5 | There was no contact number passed in. |
-6 | The contact number passed in is either invalid, does not exist in your contact list, or has unsubscribed. |
-7 | The alphanumeric sender ID passed in is either invalid(doesn't match requirements below) OR the user account does not have permission to send from an alphanumeric sender ID. |
-8 | The recurring flag passed in is invalid. Proper values are either 1 or 0. |
-9 | The repeat parameter passed in is invalid. Proper values are 'Daily', 'Weekly', 'Monthly', 'Yearly'. Also, if recurring flag is 1 and nothing passed in for this field will trip this error. |
-10 | The frequency parameter passed in is invalid. Proper values are 1-30. Also, if recurring flag is 1 and nothing passed in for this field will trip this error. |
-11 | Must have a recurring end date if you want to schedule a recurring event. The recurring flag is 1 and nothing passed in for enddate. |
-12 | Not enough credits to send the message. |
-16 | Other error. |
-20 | Level 1 does not have access to the API. API can only be used with Levels 2, 3, and 4. |
Example API Response (data is returned in universal and lightweight JSON format)
{
"status":"-3",
"msg":"The 'from' number passed in doesn't exist in your account or isn't SMS-enabled."
}