【问题标题】:Smpp receive sms in phpsmpp在php中接收短信
【发布时间】:2016-06-08 05:19:15
【问题描述】:

当与 SMSC 建立持久连接时,如何连续运行以下代码。以及这里 setRecvTimeout(60000) 的明确含义是什么。

   <?php   //Receive sms

require_once 'smppclient.class.php';
require_once 'sockettransport.class.php';

// Construct transport and client
$transport = new SocketTransport(array('smpp.provider.com'),3600);
$transport->setRecvTimeout(60000); // for this example wait up to 60 seconds for data

for(;;){
$smpp = new SmppClient($transport);

// Activate binary hex-output of server interaction
$smpp->debug = true;
$transport->debug = true;

// Open the connection
$transport->open();
$smpp->bindReceiver("USERNAME","PASSWORD");

// Read SMS and output
$sms = $smpp->readSMS();

$read = $sms -> message;// reads the message
echo $read."\n";

$phone = $sms -> source-> value; //gets the phone number
echo $phone."\n"; 

echo "SMS:\n";
//var_dump($sms);

// Close connection
$smpp->close();

}
?>

【问题讨论】:

    标签: php smpp


    【解决方案1】:

    这只是意味着将内部超时设置为 60 秒。所以如果60秒后没有收到任何东西,就说明连接断开了。

    这是超时的一般原则。

    【讨论】:

    • 如果有人能告诉我有什么方法可以连续运行这段代码?
    • 设置超时是否会成为连续运行此代码的问题?
    • 那应该是无关紧要的。你已经试过了吗?如果没有,请继续!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-02-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多