Plug-and-play code snippets for PHP cURL, Python, Node.js, Java, C#, and cURL CLI with 1-click clipboard copy:
# Send Single/Multiple SMS via HTTP GET
curl -X GET "http://cloud.smsindiahub.in/vendorsms/pushsms.aspx?user=Username&password=Password&msisdn=919876543210&sid=SMSHUB&msg=Your+OTP+is+482910&fl=0&gwid=2"
# Or REST POST with JSON Payload
curl -X POST "https://api.smsindiahub.in/api/mt/SendSMS" \
-H "Content-Type: application/json" \
-d '{
"Account.APIKey": "YOUR_API_KEY",
"SenderId": "SMSHUB",
"Message": "Your OTP is 482910 for login. Valid for 10 mins. - SMSIndiaHub",
"Channel": "2",
"DCS": "0",
"FlashSMS": "0",
"Number": "919876543210",
"Route": "1"
}'
<?php
// PHP cURL Implementation for SMSINDIAHUB Gateway
$apiKey = "YOUR_API_KEY";
$senderId = "SMSHUB";
$mobile = "919876543210";
$message = urlencode("Your OTP is 482910 for login. Valid for 10 mins. - SMSIndiaHub");
$url = "https://api.smsindiahub.in/api/mt/SendSMS?Account.APIKey={$apiKey}&SenderId={$senderId}&Number={$mobile}&Message={$message}&Channel=2&DCS=0&FlashSMS=0&Route=1";
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 15,
CURLOPT_CUSTOMREQUEST => "GET",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error: " . $err;
} else {
$data = json_decode($response, true);
print_r($data);
}
?>
import requests
url = "https://api.smsindiahub.in/api/mt/SendSMS"
payload = {
"Account.APIKey": "YOUR_API_KEY",
"SenderId": "SMSHUB",
"Message": "Your OTP is 482910 for login. Valid for 10 mins. - SMSIndiaHub",
"Channel": "2",
"DCS": "0",
"FlashSMS": "0",
"Number": "919876543210",
"Route": "1",
"PEId": "1101234567890123456",
"TemplateId": "1107123456789012345"
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
if response.status_code == 200:
print("Response JSON:", response.json())
else:
print("Error:", response.status_code, response.text)
const axios = require('axios');
const payload = {
"Account.APIKey": "YOUR_API_KEY",
"SenderId": "SMSHUB",
"Message": "Your OTP is 482910 for login. Valid for 10 mins. - SMSIndiaHub",
"Channel": "2",
"DCS": "0",
"FlashSMS": "0",
"Number": "919876543210",
"Route": "1",
"PEId": "1101234567890123456",
"TemplateId": "1107123456789012345"
};
axios.post('https://api.smsindiahub.in/api/mt/SendSMS', payload)
.then(response => {
console.log('Delivery Response:', response.data);
})
.catch(error => {
console.error('API Error:', error.message);
});
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLEncoder;
public class SMSIndiaHubClient {
public static void main(String[] args) {
try {
String user = "Username";
String password = "Password";
String msisdn = "919876543210";
String sid = "SMSHUB";
String msg = URLEncoder.encode("Your OTP is 482910", "UTF-8");
String endpoint = "http://cloud.smsindiahub.in/vendorsms/pushsms.aspx?"
+ "user=" + user + "&password=" + password
+ "&msisdn=" + msisdn + "&sid=" + sid
+ "&msg=" + msg + "&fl=0&gwid=2";
URL url = new URL(endpoint);
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod("GET");
BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream()));
String line;
StringBuilder response = new StringBuilder();
while ((line = in.readLine()) != null) {
response.append(line);
}
in.close();
System.out.println("Gateway Response: " + response.toString());
} catch (Exception e) {
e.printStackTrace();
}
}
}
using System;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
class Program
{
static async Task Main(string[] args)
{
using (var client = new HttpClient())
{
var json = "{\"Account.APIKey\":\"YOUR_API_KEY\",\"SenderId\":\"SMSHUB\",\"Message\":\"Your OTP is 482910\",\"Number\":\"919876543210\",\"Channel\":\"2\",\"DCS\":\"0\",\"Route\":\"1\"}";
var content = new StringContent(json, Encoding.UTF8, "application/json");
var response = await client.PostAsync("https://api.smsindiahub.in/api/mt/SendSMS", content);
var result = await response.Content.ReadAsStringAsync();
Console.WriteLine(result);
}
}
}