PHP code example of contactamx / sms

1. Go to this page and download the library: Download contactamx/sms 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/ */

    

contactamx / sms example snippets

bash


    ctamx\Sms\Bulker;
    $bulker = new Bulker();
    $bulker->setToken(YOUR_TOKEN_PROVIDED_BY_CONTACTA);
    
    // For send sms transactional
    $result = $bulker->sendMessage(YOUR_PHONE,YOUR_MESSAGE);
    if ($result->success) {
        
        echo "The id of the message is " . $result->id .PHP_EOL;
        echo "The message sent on  " . $result->added_on .PHP_EOL;
        echo "Additional data " . print_r($result->country, true) .PHP_EOL;
    
        $get_log = $bulker->check($result->id);
        print_r($get_log);
    }
    else{
        echo "Houston, we have a troubles: " .PHP_EOL. print_r($result, true) ;
    }
    
    // For send flash transactional
    $result = $bulker->sendFlash(YOUR_PHONE,YOUR_MESSAGE);
    if ($result->success) {
        
        echo "The id of the message is " . $result->id .PHP_EOL;
        echo "The message sent on  " . $result->added_on .PHP_EOL;
        echo "Additional data " . print_r($result->country, true) .PHP_EOL;
    
        $get_log = $bulker->check($result->id);
        print_r($get_log);
    }
    else{
        echo "Houston, we have a troubles: " .PHP_EOL. print_r($result, true) ;
    }

    // For send otp message
    $result = $bulker->sendOtp(YOUR_PHONE,YOUR_MESSAGE);
    if ($result->success) {
        
        echo "The id of the message is " . $result->id .PHP_EOL;
        echo "The message sent on  " . $result->added_on .PHP_EOL;
        echo "Additional data " . print_r($result->country, true) .PHP_EOL;
    
        $get_log = $bulker->check($result->id);
        print_r($get_log);
    
        $verify_otp = $bulker->verifyOtp(YOUR_PHONE,YOUR_OTP_CODE);
        print_r($result);
    }
    else{
        echo "Houston, we have a troubles: " .PHP_EOL. print_r($result, true) ;
    }