PHP code example of wearesho-team / alphasms-message-delivery

1. Go to this page and download the library: Download wearesho-team/alphasms-message-delivery 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/ */

    

wearesho-team / alphasms-message-delivery example snippets


# Check balance
./alphasms balance
# Send messages interactively
./alphasms send



/** @var \Wearesho\Delivery\AlphaSms\Service $service */

// Create a Voice OTP request
$request = new \Wearesho\Delivery\AlphaSms\VoiceOtp\Request(
    id: 12345,                  // Unique identifier for the request
    phoneNumber: '380991234567' // Phone number to receive the voice call
);

try {
    // Send the Voice OTP request
    $response = $service->voiceOtp($request);

    // Get the OTP code (4 digits)
    $code = $response->code();

    // Get the price of the operation
    $price = $response->price();

    echo "Voice OTP sent successfully. Code: {$code}, Price: {$price}";
} catch (\Wearesho\Delivery\Exception $e) {
    // Handle delivery exceptions
    echo "Failed to send Voice OTP: " . $e->getMessage();
}