Skip to main content

Prerequisites

Before you begin:

  • A SpringEdge account with an API key and your SMS service URL (<SMS_SERVICE_URL>, shared after sign-up)
  • PHP 7.4 or higher with the cURL extension enabled
  • A DLT-registered sender ID and approved message template (for India)

Zero Dependencies

Uses PHP's built-in cURL — no Composer packages needed

Simple HTTP API

Form-encoded GET/POST request, JSON or XML responses

HTTPS + API Key

API key sent as a request parameter over TLS, with optional IP whitelisting

<?php
$url = '<SMS_SERVICE_URL>/api/web/send/';

$params = [
    'apikey'  => 'YOUR_API_KEY',
    'sender'  => 'SEDEMO',
    'to'      => '9900XXXXXX',
    'message' => 'Your OTP is 482910',
    'format'  => 'json',
];

$ch = curl_init($url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS,
    http_build_query($params));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);

$response = curl_exec($ch);
if ($response === false) {
    die('cURL error: ' . curl_error($ch));
}
curl_close($ch);

$result = json_decode($response, true);
if ($result === null) {
    // Errors are plain text, e.g. "Invalid Sender ID"
    echo "Error: $response\n";
} else {
    echo "Message ID: {$result['MessageIDs']}\n";
}

// Success response (format=json):
// {"groupID": 61, "MessageIDs": "61-1",
//  "status": "AWAITED-DLR"}
?>

PHP cURL

Basic PHP Example

This example uses PHP's built-in curl functions to send an SMS through the SpringEdge API: a form-encoded POST to <SMS_SERVICE_URL>/api/web/send/, with your API key passed as the apikey parameter. No Composer dependencies needed.

Errors come back as plain-text messages such as Invalid Mobile Numbers or Insufficient Credits. See the SMS API documentation for all parameters.

Quick Start:

  1. Replace YOUR_API_KEY with your SpringEdge API key
  2. Replace <SMS_SERVICE_URL>, the sender ID, number, and message (must match a DLT-approved template)
  3. Run: php send_sms.php
  4. Check the response for the MessageIDs value

LARAVEL

Laravel Service Class

For Laravel applications, create a service class in app/Services/ that wraps the SMS API. Call it from any controller, job, or event listener:

app(SmsService::class)->send('9900XXXXXX', 'Your OTP is 482910');

Store your API key and SMS service URL in .env (e.g. SPRINGEDGE_API_KEY, SPRINGEDGE_URL) and map them to config('services.springedge.key') and config('services.springedge.url'). Keep the key server-side only.

<?php
// app/Services/SmsService.php
namespace App\Services;

use Illuminate\Support\Facades\Http;

class SmsService
{
    public function send(
        string $phone,
        string $message
    ): array {
        $response = Http::asForm()->post(
            config('services.springedge.url')
            . '/api/web/send/',
            [
                'apikey'  => config('services.springedge.key'),
                'sender'  => 'SEDEMO',
                'to'      => $phone,
                'message' => $message,
                'format'  => 'json',
            ]
        );

        // JSON on success, plain-text message on error
        return $response->json()
            ?? ['error' => $response->body()];
    }
}
?>

What You Can Build

OTP Verification

Add phone number verification to your PHP/Laravel signup and login flows with one-time passwords.

Order Notifications

Send automated order confirmations, shipping updates, and delivery alerts from your PHP e-commerce backend.

WordPress Plugins

Build custom WordPress plugins that send SMS notifications from WooCommerce, Contact Form 7, or Gravity Forms.

CRM Integration

Connect your PHP-based CRM to send automated SMS alerts triggered by lead capture, deal updates, and task reminders.