<?php

#require_once 'yapd/dbg.php';
require_once 'app.php';
if (!getFormParam('from') || !getFormParam('to') || !getFormParam('message')) {
    redirectWithFormError('send-message-form.php', 'From, to and message are mandatory');
}
// Construct the sms message object:
$message = new SMSRequest();
$message->senderAddress = getFormParam('from');
$message->address = getFormParam('to');
$message->message = getFormParam('message');
$message->notifyURL = getFormParam('notifyURL');
// Initialize the client:
$smsClient = new SmsClient(USERNAME, PASSWORD);
try {
    $result = $smsClient->sendSMS($message);
    redirectWithFormSuccess('send-message-form.php', '<h1>Message sent</h1><a href="check-delivery-status-form.php?clientCorrelator=' . $result->clientCorrelator . '">check delivery status</a>');
    return;
} catch (Exception $e) {
    redirectWithFormError('send-message-form.php', 'Error sending message:' . $e->getMessage());
    return;
}
<?php

use infobip\DataConnectionProfileClient;
require_once 'app.php';
$address = getFormParam('address');
$notifyURL = getFormParam('notifyURL');
if (!$address) {
    redirectWithFormError('send-roaming-status-form.php', 'Address field is mandatory');
}
// Initialize the client:
$dataConnectionProfileClient = new DataConnectionProfileClient(USERNAME, PASSWORD);
try {
    if ($notifyURL) {
        $result = $dataConnectionProfileClient->retrieveRoamingStatus($address, $notifyURL);
        $message = '<h1>Request sent</h1>';
        $message .= '<p>The result will be pushed back to ' . $notifyURL . '</p>';
        redirectWithFormSuccess('send-roaming-status-form.php', $message);
    } else {
        $result = $dataConnectionProfileClient->retrieveRoamingStatus($address);
        $message = '<h1>Request sent</h1>';
        $message .= '<p>Mobile network code: ' . $result->servingMccMnc->mnc . '</p>';
        $message .= '<p>Mobile country code: ' . $result->servingMccMnc->mcc . '</p>';
        $message .= '<p>Roaming status: ' . $result->currentRoaming . '</p>';
        redirectWithFormSuccess('send-roaming-status-form.php', $message);
    }
} catch (Exception $e) {
    redirectWithFormError('send-roaming-status-form.php', 'Error checking roaming status:' . $e->getMessage());
    return;
}
<?php

use infobip\SmsClient;
require_once 'app.php';
$clientCorrelator = getFormParam('clientCorrelator');
if (!$clientCorrelator) {
    redirectWithFormError('check-delivery-status-form.php', 'Client correlator is mandatory');
}
// Initialize the client:
$smsClient = new SmsClient(USERNAME, PASSWORD);
try {
    $result = $smsClient->queryDeliveryStatus($clientCorrelator);
    redirectWithFormSuccess('check-delivery-status-form.php', '<h1>Delivery status is ' . $result->deliveryInfo[0]->deliveryStatus . '</h1>');
    return;
} catch (Exception $e) {
    redirectWithFormError('check-delivery-status-form.php', 'Error sending message:' . $e->getMessage());
    return;
}