PHP code example of iraqotpapi / otp
1. Go to this page and download the library: Download iraqotpapi/otp library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
iraqotpapi / otp example snippets
bash
TPAPI\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);