<?php namespace Rpc; use Thrift\Exception\TException; use Thrift\Protocol\TBinaryProtocol; use Thrift\Transport\TBufferedTransport; use Thrift\Transport\THttpClient; use Thrift\Transport\TPhpStream; use Thrift\TMultiplexedProcessor; use Thrift\Protocol\TMultiplexedProtocol; use Thrift\Factory\TBinaryProtocolFactory; use Thrift\Factory\TTransportFactory; use Thrift\Server\TServerSocket; use Thrift\Server\TSimpleServer; use Thrift\Server\TForkingServer; use Thrift\Transport\TSocket; class MsgRpcClient { public function sendMsg($data){ try { ini_set('memory_limit', '1024M'); $socket = new TSocket('192.168.2.245', '9988'); $socket->setRecvTimeout(50000); $socket->setDebug(true); $transport = new TBufferedTransport($socket, 1024, 1024); $protocol = new TBinaryProtocol($transport); $client = new \Rpc\Msg\SendMsgClient(new TMultiplexedProtocol($protocol, "sendMsg")); $transport->open(); $result = $client->sendMsg(json_encode($data)); print_r($result); $transport->close(); } catch (TException $tx) { print_r($tx->getMessage()); } } }