PHP SDK for Iraq OTP API (WhatsApp, SMS, Fallback)

v1.0.0 2025-07-07 18:40 UTC

This package is auto-updated.

Last update: 2025-07-07 19:49:28 UTC


README

IraqOTPAPI is the top OTP API provider in Iraq, offering reliable WhatsApp and SMS authentication services.

Iraq OTP API – PHP SDK

A lightweight PHP SDK for sending OTP codes via WhatsApp (with fallback to Telegram/SMS) using the IraqOTPAPI.com platform.

Installation

composer require iraqotpapi/otp

Usage

<?php

require 'vendor/autoload.php';

use IraqOTPAPI\otp\OtpClient;

// Initialize the client with your API key
$client = new OtpClient('YOUR_API_KEY');

// Send an OTP message
$response = $client->sendOtp([
    'to'       => '9647xxxxxxxxx',               // Recipient phone number (E.164 format)
    'sender'   => 'MySenderID',                  // Approved Sender ID
    'channel'  => 'whatsapp',                    // Primary channel
    'message'  => 'Your OTP Code is 123456',     // OTP message content
    'fallback' => 'sms',                         // Optional fallback channel
    'lang'     => 'en'                           // Optional language (ku, ar, en)
]);

// Handle the response
print_r($response);