forked from mobiletulip/messagebird-sms-api-php
-
Notifications
You must be signed in to change notification settings - Fork 0
/
example.php
executable file
·55 lines (41 loc) · 1.94 KB
/
example.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<?php
/**
* =======================================================================
* File: example_form.php
* Author: MessageBird B.V.
*
* 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)
$sms->sendSms('This is a test message');
echo "\nResponse:";
echo "\n" . $sms->getResponseCode();
echo "\n" . $sms->getResponseMessage();
echo "\n";