<?php
$GLOBALS['SMPP_ROOT'] = dirname(__FILE__); // assumes this file is in the root
require_once $GLOBALS['SMPP_ROOT'].'/protocol/smppclient.class.php';
require_once $GLOBALS['SMPP_ROOT'].'/protocol/gsmencoder.class.php';
require_once $GLOBALS['SMPP_ROOT'].'/transport/tsocket.class.php';
// Simple debug callback
function printDebug($str) {
//echo date('Ymd H:i:s ').$str."\r\n";
}
try {
// Construct transport and client, customize settings
$transport = new TSocket('192.168.111.1',5016,false,'printDebug'); // hostname/ip (ie. localhost) and port (ie. 2775)
//print_r($transport);
$transport->setRecvTimeout(10000);
$transport->setSendTimeout(10000);
$smpp = new SmppClient($transport,'printDebug');
print_r($smpp);
// Activate debug of server interaction
$smpp->debug = true; // binary hex-output
$transport->setDebug(true); // also get TSocket debug
// Open the connection
$transport->open();
$smpp->bindTransmitter("username","password");
// Prepare message
$message = 'Hello world';
$encodedMessage = GsmEncoder::utf8_to_gsm0338($message);
$from = new SmppAddress(GsmEncoder::utf8_to_gsm0338('5672'),SMPP::TON_ALPHANUMERIC);
$to = new SmppAddress('967777841622',SMPP::TON_INTERNATIONAL,SMPP::NPI_E164);
// Send
$smpp->sendSMS($from,$to,$encodedMessage);
//print_r($smpp);
// Close connection
// print_r($smpp);
$smpp->close();
} catch (Exception $e) {
// Try to unbind
try {
$smpp->close();
} catch (Exception $ue) {
// if that fails just close the transport
printDebug("Failed to unbind; '".$ue->getMessage()."' closing transport");
if ($transport->isOpen()) $transport->close();
}
// Rethrow exception, now we are unbound or transport is closed
throw $e;
}
I found this issue belong into SMPP interface version , which php-smpp project from onlinecity on GitHub using v3.4 [0x34] , however, this version is blocked from SMSC. when I changed the interface version from 3.4 [0x34] into 0.3 [0x03] code working fine.