무료 라이브러리 this을 사용하여 PHP를 통해 SMPP 연결을 설정하고 있습니다. 나는이 브라우저 창에서 스크립트를 실행하고 주어진 60 초 이내에 정확하게 내 휴대 전화에서 SMS를 보낼 때 그것은 잘 완벽하게 작동SMPP 연결
<?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'].'/transport/tsocket.class.php';
// Construct transport and client
$transport = new TSocket('your.smsc.com',2775);
$transport->setRecvTimeout(60000); // for this example wait up to 60 seconds for data
$smpp = new SmppClient($transport);
// Activate binary hex-output of server interaction
$smpp->debug = true;
// Open the connection
$transport->open();
$smpp->bindReceiver("USERNAME","PASSWORD");
// Read SMS and output
$sms = $smpp->readSMS();
echo "SMS:\n";
var_dump($sms);
// Close connection
$smpp->close();
?>
: 메시지를 수신하기 위해, 나는 예에서 주어진 다음 코드를 사용하고 있습니다 , 그러나 나는 오랫동안 그것을 작동시키는 방법을 꽤 이해하지 못한다. 실제 상황과 마찬가지로 SMS를받을 때 백그라운드에서 실행되어 일부 이벤트가 트리거되어야합니다. 어떻게해야합니까? 이제는 SMS를 받기 위해 매번 페이지를 새로 고쳐야하며 한 번만 작동합니다. 미리 감사드립니다.
적절한 http 또는 html 헤더를 작성하는 것이 좋습니다. 둘 중 가장 적합한 방법이 매분마다 새로 고침됩니다. – chris
setRecvTimeout을 (-1) –
@SamuelCook으로 설정해 보았습니까?이 작업은 한 번만 계속됩니다. – nicks