/
sendsmstest.php
41 lines (33 loc) · 1.2 KB
/
sendsmstest.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
<?php
require_once 'smppclient.class.php';
require_once 'gsmencoder.class.php';
require_once 'sockettransport.class.php';
// Construct transport and client
$transport = new SocketTransport(array('127.0.0.1'),2775);
$transport->setRecvTimeout(100000);
$smpp = new SmppClient($transport);
// Activate binary hex-output of server interaction
$smpp->debug = true;
$transport->debug = true;
// Open the connection
$transport->open();
$smpp->bindTransmitter("demouser","demopass");
// Optional connection specific overrides
//SmppClient::$sms_null_terminate_octetstrings = false;
//SmppClient::$csms_method = SmppClient::CSMS_PAYLOAD;
//SmppClient::$sms_registered_delivery_flag = SMPP::REG_DELIVERY_SMSC_BOTH;
// Prepare message
$tags = array();
$from = new SmppAddress('SMSIND',SMPP::TON_ALPHANUMERIC);
$to = new SmppAddress(919942012345,SMPP::TON_INTERNATIONAL,SMPP::NPI_E164);
for($i=0;$i<1;$i++) {
$message = 'Hello sms from Mr.ABC'.$i.'.';
//$encodedMessage = $message;
$encodedMessage = utf8_encode($message);
// $encodedMessage = GsmEncoder::utf8_to_gsm0338($message);
// Send
$msgid = $smpp->sendSMS($from,$to,$encodedMessage,$tags);
print 'message ref id: '.$msgid;
}
// Close connection
$smpp->close();