<?php

require_once 'app.php';
$result = SmsClient::unserializeInboundMessages();
// Process the inbound message here...
// ...
// We'll just save this object:
$fileName = PUSH_LOG_DIRECTORY . '/inbound-message-' . strftime('%Y-%m-%d %H:%M') . '.txt';
$data = print_r($result, true);
file_put_contents($fileName, $data);
// We'll send a response here:
$message = new SMSRequest();
$message->senderAddress = $result->destinationAddress;
$message->address = $result->senderAddress;
$message->message = 'Thank you for your message (' . $result->message . ')!';
// Initialize the client:
$smsClient = new SmsClient(USERNAME, PASSWORD);
$result = $smsClient->sendSMS($message);
// Not needed, but just for testing:
echo 'OK';
<?php

require_once '../oneapi/client.php';
define(FILE_NAME, '../message-' . mktime(true));
# example:on-mo
// returns a single message not array of messages
$inboundMessages = SmsClient::unserializeInboundMessages();
// Process $inboundMessages here, e.g. just save it to a file:
$f = fopen(FILE_NAME, 'w');
fwrite($f, "\n-------------------------------------\n");
fwrite($f, 'dateTime: ' . $inboundMessages->dateTime . "\n");
fwrite($f, 'destinationAddress: ' . $inboundMessages->destinationAddress . "\n");
fwrite($f, 'messageId: ' . $inboundMessages->messageId . "\n");
fwrite($f, 'message: ' . $inboundMessages->message . "\n");
fwrite($f, 'resourceURL: ' . $inboundMessages->resourceURL . "\n");
fwrite($f, 'senderAddress: ' . $inboundMessages->senderAddress . "\n");
# ----------------------------------------------------------------------------------------------------
echo 'OK';