为什么 SMPP 绑定发送器 return 错误 0x34 (ESME_RINVDLNAME)
Why SMPP bind Transmitter return error 0x34 (ESME_RINVDLNAME)
这是我第一次编写 PHP 通过
发送短信的代码
SMPP [Short Message peer to Peer] 协议,来自 onlinecity php-来自 gethub URL 的 smpp 库:**https://github.com/onlinecity/php-smpp**,
我使用下面的代码发送短信,但它只响应一个错误
**return 值为错误 0x34 (ESME_RINVDLNAME) 无效的分发列表名称。**
所以请帮我解决这个错误
<?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;
}
我发现这个问题属于 SMPP 接口版本,php-smpp 项目来自 onlinecity on GitHub 使用 v3.4 [0x34],但是,此版本已被 SMSC 阻止。
当我将接口版本从 3.4 [0x34] 更改为 0.3 [0x03]
代码工作正常。
这是我第一次编写 PHP 通过
发送短信的代码 SMPP [Short Message peer to Peer] 协议,来自 onlinecity php-来自 gethub URL 的 smpp 库:**https://github.com/onlinecity/php-smpp**, 我使用下面的代码发送短信,但它只响应一个错误 **return 值为错误 0x34 (ESME_RINVDLNAME) 无效的分发列表名称。** 所以请帮我解决这个错误
<?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;
}
我发现这个问题属于 SMPP 接口版本,php-smpp 项目来自 onlinecity on GitHub 使用 v3.4 [0x34],但是,此版本已被 SMSC 阻止。 当我将接口版本从 3.4 [0x34] 更改为 0.3 [0x03] 代码工作正常。