示例#1
0
文件: smpp.php 项目: realkazan/smppi
function smpp_check($smpp_hosts, $smpp_port, $smpp_login, $smpp_password, $smpp_from, $smpp_id)
{
    require_once '../httpsdocs/includes/smpp/smppclient.class.php';
    require_once '../httpsdocs/includes/smpp/sockettransport.class.php';
    $transport = new SocketTransport($smpp_hosts, $smpp_port);
    $transport->setRecvTimeout(10000);
    $smpp = new SmppClient($transport);
    $smpp->debug = false;
    $transport->debug = false;
    $transport->open();
    $smpp->bindTransmitter($smpp_login, $smpp_password);
    $source = new SmppAddress($smpp_from, SMPP::TON_ALPHANUMERIC);
    if ($smpp_res = $smpp->queryStatus($smpp_id, $source)) {
        $smpp->close();
        return $smpp_res;
    } else {
        $smpp->close();
        return false;
    }
}
示例#2
0
文件: Sender.php 项目: Jay1991/Sms
 /**
  * {@inheritDoc}
  */
 public function send(SmsInterface $sms, GatewayInterface $gateway)
 {
     // Get the gateway configurations
     $configs = $gateway->getConfigs();
     // Create a new socket transport
     $transport = new \SocketTransport(array($gateway->getHost()), $gateway->getPort(), $configs['persistent']);
     $transport->setSendTimeout($configs['send_timeout']);
     $transport->setRecvTimeout($configs['receive_timeout']);
     $transport->debug = $configs['debug'];
     // Create a new SMPP client
     $smpp = new \SmppClient($transport);
     $smpp->debug = $configs['debug'];
     // Open the connection
     $transport->open();
     $smpp->bindTransmitter($gateway->getUsername(), $gateway->getPassword());
     // Configure a sender, recipient and message
     $sender = new \SmppAddress($sms->getSender(), $configs['sender']['ton'], $configs['sender']['npi']);
     $recipient = new \SmppAddress($sms->getRecipient(), $configs['recipient']['ton'], $configs['recipient']['npi']);
     $message = \GsmEncoder::utf8_to_gsm0338($sms->getMessage());
     // Send an SMS and close the connection
     $messageId = $smpp->sendSMS($sender, $recipient, $message);
     $smpp->close();
     return $messageId;
 }
示例#3
0
require_once 'sockettransport.class.php';
// Construct transport and client
$transport = new SocketTransport(array('127.0.0.1'), 2775);
$transport->setRecvTimeout(100000);
$smpp = new SmppClient($transport);
// Activate binary hex-output of server interaction
$smpp->debug = true;
$transport->debug = true;
// Open the connection
$transport->open();
$smpp->bindTransmitter("demouser", "demopass");
// Optional connection specific overrides
//SmppClient::$sms_null_terminate_octetstrings = false;
//SmppClient::$csms_method = SmppClient::CSMS_PAYLOAD;
//SmppClient::$sms_registered_delivery_flag = SMPP::REG_DELIVERY_SMSC_BOTH;
// Prepare message
$tags = array();
$from = new SmppAddress('SMSIND', SMPP::TON_ALPHANUMERIC);
$to = new SmppAddress(919942012345, SMPP::TON_INTERNATIONAL, SMPP::NPI_E164);
for ($i = 0; $i < 1; $i++) {
    $message = 'Hello sms from Mr.ABC' . $i . '.';
    //$encodedMessage = $message;
    $encodedMessage = utf8_encode($message);
    //  $encodedMessage = GsmEncoder::utf8_to_gsm0338($message);
    // Send
    $msgid = $smpp->sendSMS($from, $to, $encodedMessage, $tags);
    print 'message ref id: ' . $msgid;
}
// Close connection
$smpp->close();
示例#4
0
function smpp_send($smpp_hosts, $smpp_port, $smpp_login, $smpp_password, $smpp_from, $smpp_to, $smpp_msg)
{
    $transport = new SocketTransport($smpp_hosts, $smpp_port);
    $transport->setRecvTimeout(60000);
    $smpp = new SmppClient($transport);
    $tags = "CSMS_16BIT_TAGS";
    $data_coding = SMPP::DATA_CODING_ISO8859_5;
    // Cyrillic
    $smpp->debug = false;
    $transport->debug = false;
    $transport->open();
    $smpp->bindTransmitter($smpp_login, $smpp_password);
    $message = $smpp_msg;
    $encodedMessage = $message;
    $from = new SmppAddress($smpp_from, SMPP::TON_ALPHANUMERIC);
    $to = new SmppAddress($smpp_to, SMPP::TON_INTERNATIONAL, SMPP::NPI_E164);
    if ($smpp_id = $smpp->sendSMS($from, $to, $encodedMessage, $tags, $data_coding)) {
        $smpp->close();
        return trim($smpp_id);
    } else {
        $smpp->close();
        return false;
    }
}
示例#5
0
 public function smpp_check($smpp_id)
 {
     global $smpp_hosts, $smpp_port, $smpp_login, $smpp_password, $smpp_from;
     $transport = new SocketTransport($smpp_hosts, $smpp_port);
     $transport->setRecvTimeout(10000);
     $smpp = new SmppClient($transport);
     $smpp->debug = false;
     $transport->debug = false;
     $transport->open();
     $smpp->bindTransmitter($smpp_login, $smpp_password);
     $source = new SmppAddress($smpp_from, SMPP::TON_ALPHANUMERIC);
     if (!($smpp_res = $smpp->queryStatus($smpp_id, $source))) {
         $smpp->close();
         throw new Exception('SMPP check error');
     }
     return $smpp_res;
 }