Developer Resources

SMS Gateway Integration Guides

Production-ready code examples for PHP, Node.js, Python, Salesforce, WordPress, and Laravel — send your first SMS in under 5 minutes.

5 Min  Setup
🔒 HTTPS  Only
📊 Real-Time  Reports
DLT  Compliant
🐘

PHP SMS Integration

Beginner ⏱️ 15 minutes

Learn how to integrate SMS gateway with PHP using cURL and our REST API. The most popular integration method for Indian web applications.

Steps:

  1. Get your API key from the dashboard
  2. Install cURL extension if not already installed
  3. Create a new PHP file for SMS functionality
  4. Write the SMS sending function using cURL
  5. Test the integration with a sample message

Code Sample:

<?php
function sendSMS($to, $message, $apiKey) {
    $url = "https://api.onlinesmsservice.com/v1/send";
    $data = [
        "to" => $to,
        "message" => $message,
        "type" => "transactional"
    ];
    
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
    curl_setopt($ch, CURLOPT_HTTPHEADER, [
        "Content-Type: application/json",
        "Authorization: Bearer " . $apiKey
    ]);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    
    $response = curl_exec($ch);
    curl_close($ch);
    
    return json_decode($response, true);
}

// Usage
$result = sendSMS("919999999999", "Hello!", "your_api_key");
echo json_encode($result);
View Full Guide
🟢

Node.js SMS Integration

Beginner ⏱️ 20 minutes

Integrate SMS gateway with Node.js using axios and async/await. Perfect for modern JavaScript apps, Express servers, and serverless functions.

Steps:

  1. Create a new Node.js project
  2. Install axios package
  3. Create SMS service module
  4. Implement SMS sending function
  5. Add error handling and testing

Code Sample:

const axios = require("axios");

class SMSService {
    constructor(apiKey) {
        this.apiKey = apiKey;
        this.baseURL = "https://api.onlinesmsservice.com/v1";
    }
    
    async sendSMS(to, message, type = "transactional") {
        const response = await axios.post(
            `${this.baseURL}/send`,
            { to, message, type },
            {
                headers: {
                    "Authorization": `Bearer ${this.apiKey}`
                }
            }
        );
        return response.data;
    }
}

// Usage
const sms = new SMSService("your_api_key");
sms.sendSMS("919999999999", "Hello from Node.js!")
    .then(result => console.log(result));
View Full Guide
🐍

Python SMS Integration

Beginner ⏱️ 15 minutes

Send SMS using Python with the requests library and our REST API. Ideal for Django, Flask, FastAPI, and data pipeline projects.

Steps:

  1. Install requests library
  2. Create Python script for SMS
  3. Implement SMS sending function
  4. Add error handling
  5. Test the integration

Code Sample:

import requests

class SMSService:
    def __init__(self, api_key):
        self.api_key = api_key
        self.base_url = "https://api.onlinesmsservice.com/v1"
    
    def send_sms(self, to, message, msg_type="transactional"):
        headers = {
            "Content-Type": "application/json",
            "Authorization": f"Bearer {self.api_key}"
        }
        data = {"to": to, "message": message, "type": msg_type}
        
        response = requests.post(
            f"{self.base_url}/send",
            json=data, headers=headers
        )
        response.raise_for_status()
        return response.json()

# Usage
sms = SMSService("your_api_key")
result = sms.send_sms("919999999999", "Hello from Python!")
print(result)
View Full Guide
☁️

Salesforce SMS Integration

Intermediate ⏱️ 30 minutes

Integrate SMS gateway with Salesforce using Apex and REST API callouts. Automate customer communications directly from your CRM.

Steps:

  1. Create custom Apex class for SMS
  2. Implement HTTP callout method
  3. Add Remote Site Settings for our API
  4. Create Process Builder / Flow trigger
  5. Test with Salesforce org

Code Sample:

public class SMSService {
    private static final String API_URL = 
        "https://api.onlinesmsservice.com/v1/send";
    
    @future(callout=true)
    public static void sendSMS(String phone, String msg) {
        Http http = new Http();
        HttpRequest request = new HttpRequest();
        request.setEndpoint(API_URL);
        request.setMethod("POST");
        request.setHeader("Content-Type", "application/json");
        request.setHeader("Authorization", "Bearer YOUR_KEY");
        request.setBody(JSON.serialize(new Map<String, Object>{
            "to" => phone,
            "message" => msg,
            "type" => "transactional"
        }));
        
        HttpResponse response = http.send(request);
        System.debug("Status: " + response.getStatusCode());
    }
}
View Full Guide
📝

WordPress Plugin

Beginner ⏱️ 25 minutes

Add SMS functionality to WordPress using a custom plugin. Send notifications on form submissions, order updates, and more.

Steps:

  1. Create custom WordPress plugin file
  2. Add SMS settings page in WP Admin
  3. Implement SMS sending via wp_remote_post
  4. Hook into WooCommerce order events
  5. Test SMS notifications

Code Sample:

<?php
/*
Plugin Name: OnlineSMSService Gateway
Description: Integrate SMS gateway with WordPress
Version: 1.0
*/

class SMSGatewayPlugin {
    public function __construct() {
        add_action("admin_menu", [$this, "add_menu"]);
    }
    
    public function send_sms($to, $message) {
        return wp_remote_post(
            "https://api.onlinesmsservice.com/v1/send",
            [
                "headers" => [
                    "Content-Type" => "application/json",
                    "Authorization" => "Bearer " . 
                        get_option("sms_api_key")
                ],
                "body" => json_encode([
                    "to" => $to,
                    "message" => $message,
                    "type" => "transactional"
                ])
            ]
        );
    }
}
new SMSGatewayPlugin();
View Full Guide
🔴

Laravel Integration

Intermediate ⏱️ 20 minutes

Integrate SMS gateway with Laravel using a custom service provider. Leverage facades, dependency injection, and queue workers.

Steps:

  1. Create SMS service provider
  2. Register service in config/services.php
  3. Create SMS notification channel
  4. Implement via Laravel Notifications
  5. Add to Laravel queue system

Code Sample:

<?php
namespace App\Services;

use Illuminate\Support\Facades\Http;

class SMSService
{
    public function send($to, $message, $type = "transactional")
    {
        $response = Http::withHeaders([
            "Authorization" => "Bearer " . config("sms.api_key")
        ])->post(config("sms.base_url") . "/send", [
            "to" => $to,
            "message" => $message,
            "type" => $type
        ]);
        
        if ($response->successful()) {
            return $response->json();
        }
        
        throw new \Exception("SMS failed: " . $response->body());
    }
}
View Full Guide

Additional Resources

📚

API Documentation

Complete API reference with all endpoints, parameters, and response formats.

View Docs →
🔧

SDK Downloads

Official SDKs for PHP, Node.js, Python, and other popular programming languages.

Get SDKs →
📋

DLT Registration

Step-by-step guide to DLT registration and TRAI compliance for commercial SMS.

DLT Guide →
💬

Support

Need help with integration? Our support team is available 24/7 to assist you.

Get Support →

Ready to Start Integrating?

Get your free API key and start sending SMS in minutes. Our developer-friendly API makes integration effortless.

Get Free API Key View Pricing