Ejemplo n.º 1
0
 private function _send($mobiles, $message)
 {
     try {
         $socket = new TSocketPool($this->config['msg_server_host'], $this->config['msg_server_port']);
         $transport = new TFramedTransport($socket, 1024, 1024);
         $protocol = new TBinaryProtocol($transport);
         $transport->open();
         $client = new \mobilemsg\service\MsgOper_ServiceClient($protocol);
         $identity = new \mobilemsg\service\Identity(array('version' => $GLOBALS['mobilemsg_CONSTANTS']['version'], 'appId' => $this->config['app_id'], 'appKey' => $this->config['app_key']));
         $sent_control = new \mobilemsg\service\SentControl();
         $type = 0;
         $downMsg = new \mobilemsg\service\DownMsg();
         $downMsg->mobiles = $mobiles;
         $downMsg->smsContent = $this->alert->build_msg($message);
         $downMsg->muid = $mobiles[0] . '_' . time();
         $msg = array(0 => $downMsg);
         $ret = $client->send($identity, $type, $msg, $sent_control);
         $this->log("task worker {$this->worker_id}  send msg result" . var_export($ret, 1));
         //业务代码end
         $transport->close();
     } catch (TException $tx) {
         $this->log("task worker {$this->worker_id}  thrift Exception " . var_export($tx, 1));
     }
 }
Ejemplo n.º 2
0
    $transport = new TFramedTransport($socket, 1024, 1024);
    $protocol = new TBinaryProtocol($transport);
    $transport->open();
    //业务代码begin
    //注册验证码接口
    define('APPID', 77);
    define('APPKEY', 'stats20151007');
    //邀请短信接口
    //define('APPID', 44);
    //define('APPKEY', 'secretInvite');
    //define('APPID', 2);
    //define('APPKEY', 'test');
    $client = new \mobilemsg\service\MsgOper_ServiceClient($protocol);
    $identity = new \mobilemsg\service\Identity(array('version' => $GLOBALS['mobilemsg_CONSTANTS']['version'], 'appId' => APPID, 'appKey' => APPKEY));
    $sent_control = new \mobilemsg\service\SentControl();
    $type = 0;
    $downMsg = new \mobilemsg\service\DownMsg();
    $downMsg->mobiles = array('18588746832');
    $downMsg->smsContent = '验证码546688';
    $downMsg->muid = '18588746832_' . time();
    $msg = array(0 => $downMsg);
    $ret = $client->send($identity, $type, $msg, $sent_control);
    var_dump($ret);
    //业务代码end
    $transport->close();
} catch (TException $tx) {
    $result['code'] = -100;
    //thrift异常
    print_r($tx);
}
echo json_encode($result);