Send SMS API
This API endpoint allows sending an SMS via an HTTP request from the smartphone.
https://api.smsmobileapi.com/sendsms/?recipients=PHONE_NUMBER&message=MESSAGE_TO_SEND&apikey=YOUR_API_KEY
Parameters:
- recipients: The mobile number of the recipient.
- message: The message to send.
- apikey: The API key you have or will receive.
Note:
Due to obligations related to phone usage and Android's policies, we are required to increase the delay between sending two SMS messages if the application is running in the background or is closed. SMS messages can still be sent even when the mobile application is closed, but this will result in an increased dispatch delay.
Get SMS API
This API endpoint is used to retrieve SMS messages received on the smartphone.
https://api.smsmobileapi.com/getsms/?apikey=YOUR_API_KEY
Parameter:
Send SMS
WSDL URL
https://api.smsmobileapi.com/sendsms/wsdl/sendsms.wsdl
Parameters:
- recipients: The mobile number of the recipient.
- message: The message to send.
- apikey: The API key you have or will receive.
Exemple
require_once "lib/nusoap.php";
$client = new nusoap_client("https://api.smsmobileapi.com/sendsms/wsdl/sendsms.wsdl", true);
$error = $client->getError();
$result = $client->call("sendSms", array("recipients" =>$_GET['recipients'],"message" =>$_GET['message'],"apikey" =>$_GET['apikey']));
print_r($result);
Send SMS
Basic cURL Command
You can use the following cURL command to send an SMS via the SMSmobileAPI:
curl -X POST https://api.smsmobileapi.com/sendsms/ \
-d "recipients=PHONE_NUMBER" \
-d "message=YOUR_MESSAGE" \
-d "apikey=YOUR_API_KEY"
cURL Example in PHP
If you're using PHP, here's how you can send an SMS using cURL:
<?php
$url = 'https://api.smsmobileapi.com/sendsms/';
$data = array(
'recipients' => 'PHONE_NUMBER',
'message' => 'YOUR_MESSAGE',
'apikey' => 'YOUR_API_KEY'
);
$options = array(
CURLOPT_URL => $url,
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => http_build_query($data),
CURLOPT_RETURNTRANSFER => true,
);
$ch = curl_init();
curl_setopt_array($ch, $options);
$response = curl_exec($ch);
curl_close($ch);
echo $response;
?>
This PHP example demonstrates how to send a POST request using cURL to the SMSmobileAPI, passing the necessary parameters as an associative array.
Send SMS
Use our officiel Python Module : https://smsmobileapi.com/python/ or use the manuel way ...
Using the `requests` Library
The `requests` library is a popular and simple HTTP library for Python. Here's how you can use it to send an SMS via the SMSmobileAPI:
import requests
url = "https://api.smsmobileapi.com/sendsms/"
payload = {
"recipients": "PHONE_NUMBER",
"message": "YOUR_MESSAGE",
"apikey": "YOUR_API_KEY"
}
response = requests.post(url, data=payload)
print(response.text)
This example demonstrates a simple POST request to the SMSmobileAPI, sending a message to a specific phone number.
Using the `http.client` Library
The `http.client` library is included in the standard library of Python and can also be used to interact with your API:
import http.client
import urllib.parse
conn = http.client.HTTPSConnection("api.smsmobileapi.com")
params = urllib.parse.urlencode({
"recipients": "PHONE_NUMBER",
"message": "YOUR_MESSAGE",
"apikey": "YOUR_API_KEY"
})
headers = { "Content-type": "application/x-www-form-urlencoded" }
conn.request("POST", "/sendsms/", params, headers)
response = conn.getresponse()
data = response.read()
print(data.decode("utf-8"))
conn.close()
This example shows how to use the `http.client` library to send a POST request to the API. The parameters are URL-encoded and sent with the appropriate headers.
Send SMS
Using the `fetch` API
The `fetch` API is a modern and versatile way to make HTTP requests in JavaScript. Here's how you can use it to send an SMS via the SMSmobileAPI:
const url = "https://api.smsmobileapi.com/sendsms/";
const data = {
recipients: "PHONE_NUMBER",
message: "YOUR_MESSAGE",
apikey: "YOUR_API_KEY"
};
fetch(url, {
method: "POST",
headers: {
"Content-Type": "application/x-www-form-urlencoded"
},
body: new URLSearchParams(data)
})
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.error("Error:", error));
This example demonstrates how to send a POST request using the `fetch` API, which is supported in most modern browsers.
Using `XMLHttpRequest`
If you need to support older browsers, you can use the `XMLHttpRequest` object:
const xhr = new XMLHttpRequest();
const url = "https://api.smsmobileapi.com/sendsms/";
const data = "recipients=PHONE_NUMBER&message=YOUR_MESSAGE&apikey=YOUR_API_KEY";
xhr.open("POST", url, true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.onreadystatechange = function() {
if (xhr.readyState === 4 && xhr.status === 200) {
console.log(xhr.responseText);
}
};
xhr.send(data);
This example shows how to use `XMLHttpRequest` to send a POST request, providing compatibility with older browsers that may not support `fetch`.
Send SMS
Using the `axios` Library
The `axios` library is a popular HTTP client for Node.js. Here's how you can use it to send an SMS via the SMSmobileAPI:
const axios = require('axios');
const url = 'https://api.smsmobileapi.com/sendsms/';
const data = {
recipients: 'PHONE_NUMBER',
message: 'YOUR_MESSAGE',
apikey: 'YOUR_API_KEY'
};
axios.post(url, data)
.then(response => {
console.log(response.data);
})
.catch(error => {
console.error('Error:', error);
});
This example demonstrates how to send a POST request using `axios` in Node.js to interact with the SMSmobileAPI.
Send SMS
Using the `Net::HTTP` Library
You can use the `Net::HTTP` library in Ruby to send an SMS via the SMSmobileAPI:
require 'net/http'
require 'uri'
uri = URI.parse("https://api.smsmobileapi.com/sendsms/")
request = Net::HTTP::Post.new(uri)
request.set_form_data(
"recipients" => "PHONE_NUMBER",
"message" => "YOUR_MESSAGE",
"apikey" => "YOUR_API_KEY"
)
req_options = {
use_ssl: uri.scheme == "https",
}
response = Net::HTTP.start(uri.hostname, uri.port, req_options) do |http|
http.request(request)
end
puts response.body
This example demonstrates how to send a POST request using `Net::HTTP` in Ruby to the SMSmobileAPI.