private function init($socket)
 {
     $transport = new TFramedTransport($socket, 1024, 1024);
     $protocol = new TBinaryProtocol($transport);
     $this->client = new \ipqueryClient($protocol);
     $transport->open();
 }
Esempio n. 2
0
 public function __construct($host, $port)
 {
     try {
         $socket = new TSocket($host, $port);
         $transport = new TFramedTransport($socket);
         $protocol = new TBinaryProtocol($transport);
         $transport->open();
         $this->_searchService = new ThriftSearchServiceClient($protocol);
     } catch (TException $tx) {
         throw FirteXException($tx->getMessage());
     }
 }
Esempio n. 3
0
 /**
  * Disconnect the open connection
  *
  * @return static
  *
  * @throws ConnectionException
  */
 public function disconnect()
 {
     $this->_client = null;
     if ($this->_transport instanceof TTransport) {
         $this->_transport->close();
     }
     $this->_transport = null;
     $this->_protocol = null;
     $this->_connected = false;
     return parent::disconnect();
 }
Esempio n. 4
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));
     }
 }
Esempio n. 5
0
    }
    return false;
}
$result = array('code' => 0, 'data' => array());
/*
//ip白名单判断
if( !empty($_SERVER['HTTP_X_FORWARDED_FOR']) ) $_SERVER['REMOTE_ADDR'] = $_SERVER['HTTP_X_FORWARDED_FOR'];
if( !check_ip($white_ip_array, $_SERVER['REMOTE_ADDR']) ){
	$result['code'] = -1; //ip不再白名单内
	echo json_encode($result);
	exit;
}
*/
try {
    $socket = new TSocketPool(array('115.238.170.51', '121.9.221.159', '113.106.100.79'), 30303);
    $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;
include_once $GLOBALS['SCRIBE_ROOT'] . '/scribe/thrift/scribe.php';
include_once $GLOBALS['THRIFT_ROOT'] . '/Thrift/Protocol/TProtocol.php';
include_once $GLOBALS['THRIFT_ROOT'] . '/Thrift/Protocol/TBinaryProtocol.php';
include_once $GLOBALS['THRIFT_ROOT'] . '/Thrift/Transport/TTransport.php';
include_once $GLOBALS['THRIFT_ROOT'] . '/Thrift/Transport/TFramedTransport.php';
include_once $GLOBALS['THRIFT_ROOT'] . '/Thrift/Transport/TSocket.php';
use Thrift\Protocol\TBinaryProtocol;
use Thrift\Transport\TSocket;
use Thrift\Transport\TFramedTransport;
use Thrift\Exception\TException;
use scribe\thrift\scribeClient;
use scribe\thrift\LogEntry;
use scribe\thrift\ResultCode;
try {
    $sock = new TSocket('localhost', 1463);
    $trans = new TFramedTransport($sock);
    $prot = new TBinaryProtocol($trans);
    // Create the client
    print "creating scribe client\n";
    $scribe_client = new scribeClient($prot);
    // Open the transport (we rely on PHP to close it at script termination)
    print "opening transport\n";
    $trans->open();
    $entry = new LogEntry();
    $entry->category = "PHP";
    $entry->message = "Hello to Scribe from PHP!";
    $messages[] = $entry;
    for ($x = 0; $x <= 0; $x++) {
        $result = $scribe_client->Log($messages);
        if ($result != ResultCode::OK) {
            print "Warning: Log returned {$result} \n";