PHP code example of multiotp / smsgateway

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

    

multiotp / smsgateway example snippets



use multiOTP\SMSGateway\SMSGateway;



//Import SMSGateway classes into the global namespace
//These must be at the top of your script, not inside a function
use multiOTP\SMSGateway\SMSGateway;

//Load Composer's autoloader
t
$smsgateway->setSharedSecret("secret");

$device_id   = "demo";
$to = "+1234567890";
$message = "Demo message";
$device_h = $smsgateway->calculateAuthenticationHash($device_id);

$message_id = $smsgateway->sendMessage($device_id, $to, $message);

echo "Full URL for Android app URL: https://......./?id=$device_id&h=$device_h";


//Import SMSGateway classes into the global namespace
//These must be at the top of your script, not inside a function
use multiOTP\SMSGateway\SMSGateway;

//Load Composer's autoloader
// Handling $array of new received messages
  // [["device_id"    => "device id",
  //   "message_id"   => "message id",
  //   "from"         => "from phone number",
  //   "sms_sent"     => "sms_sent timestamp (ms)",
  //   "sms_received" => "sms_received timestamp (ms)",
  //   "content"      => "message content",
  //   "last_update"  => "last update timestamp (ms)",
  //   "status"       => "UNREAD|READ"
  //  ],
  //  [...]
  // ]
}

function update_handling($array) {
  // Handling $array of status updates for sent messages
  // [["device_id"    => "device id",
  //   "message_id"   => "message id",
  //   "to"           => "to phone number",
  //   "content"      => "content",
  //   "last_update"  => "last update timestamp (ms)",
  //   "status"       => "NEW|PUSHED|PENDING|SENT|DELIVERED|FAILED"
  //  ],
  //  [...]
  // ]
}

function timeout_handling($array) {
  // Handling $array of devices not seen during the last "DeviceTimeout" seconds
  // [["device_id"   => "device_id",
  //   "last_update" => "device_last_update"
  //  ],
  //  [...]
  // ]
}

//Create an instance
$smsgateway = new SMSGateway();

// Set the data folder
$smsgateway->setDataPath(__DIR__ . DIRECTORY_SEPARATOR . 'data' . DIRECTORY_SEPARATOR);

// Launch the API server with callback functions definition
$smsgateway->apiServer("secret", "new_message_handling", "update_handling", "timeout_handling");

adb shell
settings put global sms_outgoing_check_max_count 200
settings put global sms_outgoing_check_interval_ms 60000