Exemplo n.º 1
0
 *
 *  More information? Go to www.messagebird.com/sms-api
 *
 * This class requires that you have PHP 5.1.x or higher installed.
 * ========================================================================
 */
require_once 'lib/class.Messagebird.php';
// Set the Messabeird username and password, and create an instance of the MessageBird class
$sms = new MessageBird('username', 'password');
// Set the sender, could be an number (16 numbers) or letters (11 characters)
$sms->setSender('YourSender');
// Add the destination mobile number.
// This method can be called several times to add have more then one recipient for the same message
$sms->addDestination('31600000000');
// Set an reference, optional
$sms->setReference('123456789');
// Set a schedule date-time, optional
// $sms->setTimestamp('2014-01-01 10:02');
// Replace non GSM-7 characters by appropriate valid GSM-7 characters
// $sms->setReplacechars(false);
// If you want a dlr notification of the message send to another url then that you have set on the web site, you can use this parameter. Don't forget to set a reference!
// $sms->setDlrUrl('http://www.example.com/dlr_url.php');
// The message will be send as a voice message and the gateway_id will be overwritten to 8, which is the voice gateway. (Dutch only for the moment)
// $sms->setVoice(true);
// Set the quality of the route that you want to send the message.
// $sms->setGateway('quality');
// Send a premium message
// $sms->setPremium(150, 1008, 'MessageBird');
// If $test is TRUE, then the message is not actually sent or scheduled, and there will be no credits deducted.
// $sms->setTest(true);
// Send the message to the destination(s)
    } else {
        $reference = null;
    }
    // If we have the required parameters, we can send a message.
    if ($destination !== null && $message !== null && $sender !== null) {
        $sms = new MessageBird($username, $password);
        // Add the destination mobile number.
        // This method can be called several times to add have more then one recipient for the same message
        $sms->addDestination($destination);
        if ($sender !== null) {
            // Set the sender, could be an number (16 numbers) or letters (11 characters)
            $sms->setSender($sender);
        }
        if ($reference !== null) {
            // Set an reference
            $sms->setReference($reference);
        }
        // Send the message to the destination(s)
        $sms->sendSms($message);
        // Output the response to the browser
        echo '<br />Response Info:';
        echo '<br />Response Code: ' . $sms->getResponseCode();
        echo '<br />Response Message: ' . $sms->getResponseMessage();
        echo '<br />';
        // There is no destination or message posted, we realy need those two to work.
    } else {
        echo '<br />No destination, sender or message given!';
        echo '<br />You must enter an destination, sender and message!';
    }
    // It seems there is no POST, and this example script only works with an HTTP POST.
} else {