$soap = new MMSoap($username, $password, $options);
// Check user info
echo "\n** User Info\n";
$response = $soap->getUserInfo();
if ($response instanceof SoapFault) {
    exit('Error: ' . $response->getMessage());
}
$result = $response->getResult();
$accountDetails = $result->accountDetails;
echo 'Account type: ' . $accountDetails->type . "\n";
echo $result->accountDetails->creditRemaining . " credits remaining\n";
// Send messages using rotary
echo "\n** Send Messages using rotary\n";
echo "Sending '{$message}' to " . implode(', ', $recipients) . "\n";
// Example of sending a message
$response = $soap->sendMessages($recipients, $message);
$result = $response->getResult();
echo $result->sent . ' sent / ' . $result->scheduled . ' scheduled / ' . $result->failed . " failed\n";
// Send messages using a source number
echo "\n** Send Messages using a source number.\n";
echo "Sending '{$message}' to " . implode(', ', $recipients) . "\n";
// Example of sending a message
$response = $soap->sendMessages($recipients, $message, null, $origin);
$result = $response->getResult();
echo $result->sent . ' sent / ' . $result->scheduled . ' scheduled / ' . $result->failed . " failed\n";
// Example of sending a message at a scheduled date and time
/*echo "\n** Schedule A Message\n";
echo "Scheduling to send '$message' on ".date('l jS \of F Y h:iA',$oneMinuteInTheFuture)." to " . implode(', ', $recipients) . "\n";
// This is an example of the date format $scheduled = "2016-07-28T17:10:00";
$scheduled = date('Y-m-j\TG:i:s',$oneMinuteInTheFuture);
$response = $soap->sendMessages($recipients, $message, $scheduled, $origin);
$messageIds = array('24');
$origin = "+61491570157";
// for scheduled messages lets schedule a message 1 minte in the future
$oneMinuteInTheFuture = mktime(date("H"), date("i") + 1, date("s"), date("m"), date("d"), date("Y"));
// Create new MMSoap class
$soap = new MMSoap($username, $password, $options);
// Send a simple message
$recipient = $recipients[0];
echo "\n** Send Messages\n";
echo "Sending message to {$recipient}\n";
$response = $soap->sendMessage($recipient, "messagemedia-php: simple message");
if ($response instanceof SoapFault) {
    exit('Error: ' . $response->getMessage());
}
$result = $response->getResult();
echo $result->sent . ' sent / ' . $result->scheduled . ' scheduled / ' . $result->failed . " failed\n";
// Example sending a more complex request
// - scheduled
// - source number
// - delivery report
// - sequence number
// - message ids
echo "\nScheduling to send message on " . date('l jS \\of F Y h:iA', $oneMinuteInTheFuture) . " to " . implode(', ', $recipients) . "\n";
$scheduled = date('Y-m-d\\TG:i:s', $oneMinuteInTheFuture);
$sequenceNumber = 10;
$response = $soap->sendMessages($recipients, "messagemedia-php: scheduled message", $scheduled, $origin, TRUE, $sequenceNumber, $messageIds);
if ($response instanceof SoapFault) {
    exit('Error: ' . $response->getMessage());
}
$result = $response->getResult();
echo $result->sent . ' sent / ' . $result->scheduled . ' scheduled / ' . $result->failed . " failed\n";
// if you don't want to use the credetials import, just use the below variables 
// Set up account details
$username = '******';
$password = '******';

// http://www.acma.gov.au/Citizen/Consumer-info/All-about-numbers/Special-numbers/fictitious-numbers-for-radio-film-and-television-i-acma
$recipient = "+61491570156";
*/
require 'getStdin.php';
// Create new MMSoap class
$soap = new MMSoap($username, $password, $options);
echo "** Do you want to send a message to {$recipient}, y followed by ENTER to send, or ENTER to skip.\n";
if (getStdin("y")) {
    echo "** Send message to {$recipient}\n";
    // send the message
    $response = $soap->sendMessages(array($recipient), "messagemedia-php: msg with report", null, null, TRUE);
    if ($response instanceof SoapFault) {
        exit('Error: ' . $response->getMessage());
    }
    $result = $response->getResult();
    echo $result->sent . ' sent / ' . $result->scheduled . ' scheduled / ' . $result->failed . " failed\n\n";
    // sleep a little bit to give the message time to be delivered
    sleep(5);
}
echo "** Check for reports\n";
$response = $soap->getReports();
if ($response instanceof SoapFault) {
    exit('Error: ' . $response->getMessage());
}
$result = $response->getResult();
echo "Received {$result->returned} reports, {$result->remaining} are remaining.\n";
$recipients = array($recipient);
// MessageId array matches each recipient. i.e. 61491570156 will match 24.
$messageIds = array('24');
$origin = "+61491570157";
// Create new MMSoap class
$soap = new MMSoap($username, $password, $options);
// Example sending a more complex request
// - scheduled
// - source number
// - delivery report
// - sequence number
// - message ids
// - message send mode
echo "\nTesting sending messages to " . implode(', ', $recipients) . "\n";
$sequenceNumber = 10;
$response1 = $soap->sendMessages($recipients, "messagemedia-php: drop random", null, $origin, TRUE, $sequenceNumber, $messageIds, 'dropAll');
$sequenceNumber++;
$response2 = $soap->sendMessages($recipients, "messagemedia-php: dropAllWithErrors", null, $origin, TRUE, $sequenceNumber, $messageIds, 'dropAllWithErrors');
$sequenceNumber++;
$response3 = $soap->sendMessages($recipients, "messagemedia-php: dropAllWithSuccess", null, $origin, TRUE, $sequenceNumber, $messageIds, 'dropAllWithSuccess');
if ($response1 instanceof SoapFault) {
    exit('Error: ' . $response1->getMessage());
}
$result = $response1->getResult();
echo $result->sent . ' sent / ' . $result->scheduled . ' scheduled / ' . $result->failed . " failed\n";
if ($response2 instanceof SoapFault) {
    exit('Error: ' . $response2->getMessage());
}
$result = $response2->getResult();
echo $result->sent . ' sent / ' . $result->scheduled . ' scheduled / ' . $result->failed . " failed\n";
if ($response3 instanceof SoapFault) {
Beispiel #5
0
$soap = new MMSoap($username, $password, $options);
// Check user info
echo "\n** User Info\n";
$response = $soap->getUserInfo();
if ($response instanceof SoapFault) {
    exit('Error: ' . $response->getMessage());
}
$result = $response->getResult();
$accountDetails = $result->accountDetails;
echo 'Account type: ' . $accountDetails->type . "\n";
echo $result->accountDetails->creditRemaining . " credits remaining\n";
// Send messages using rotary
echo "\n** Send Messages using rotary\n";
echo "Sending '{$message}' to " . implode(', ', $recipients) . "\n";
// Example of sending a message
$response = $soap->sendMessages($recipients, $message);
$result = $response->getResult();
echo $result->sent . ' sent / ' . $result->scheduled . ' scheduled / ' . $result->failed . " failed\n";
// Send messages using a source number
echo "\n** Send Messages using a source number.\n";
echo "Sending '{$message}' to " . implode(', ', $recipients) . "\n";
// Set this to true to request a DR, please note this will incur an additional charge
$messageId = 1239812;
$deliveryReceipt = false;
if ($deliveryReceipt) {
    echo "Request delivery Receipt.\n";
}
echo "Setting messageId to " . $messageId . "\n";
// Example of sending a message with a Delivery Receipt request and setting the message Id (1239812)
$response = $soap->sendMessages($recipients, $message, null, $origin, $deliveryReceipt, $messageId);
$result = $response->getResult();