如何解决为什么SMPP绑定发送器返回错误0x34ESME_RINVDLNAME
这是我第一次编写通过SMS发送短信的PHP代码。 来自gethub URL的onlinecity php-smpp库通过SMPP [对等短消息对等]协议:** https://github.com/onlinecity/php-smpp**, 我使用下面的代码发送短信,但它仅响应一个错误 **返回值为错误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接口版本,该版本使用v3.4 [0x34]从GitHub上的onlinecity的 php-smpp项目中,但是此版本已被SMSC阻止。 当我将接口版本从3.4 [0x34]更改为0.3 [0x03]时 代码工作正常。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。