require_once 'Thrift/ClassLoader/ThriftClassLoader.php'; require_once 'TrustedBridge/Types.php'; require_once 'TrustedBridge/TrustedBridge.php'; use Thrift\ClassLoader\ThriftClassLoader; $GEN_DIR = realpath(dirname(__FILE__) . '/..') . '/gen-php'; $loader = new ThriftClassLoader(); $loader->registerNamespace('Thrift', '.'); $loader->registerDefinition('TrustedBridge', '.'); $loader->register(); use Thrift\Protocol\TBinaryProtocol; use Thrift\Transport\TSocket; use Thrift\Transport\THttpClient; use Thrift\Transport\TPhpStream; use Thrift\Transport\TBufferedTransport; use Thrift\Exception\TException; try { echo "Connecting " . $server_ip . ":" . $server_port . "<br>"; $socket = new TSocket($server_ip, $server_port); $transport = new TBufferedTransport($socket, 1024, 1024); //$transport = new TBufferedTransport(new TPhpStream(TPhpStream::MODE_R | TPhpStream::MODE_W));; $protocol = new TBinaryProtocol($transport); $client = new \TrustedBridge\TrustedBridgeClient($protocol); $transport->open(); //$file = fopen("login.html", "rb"); $file = file_get_contents("../upload/" . $filename, FILE_USE_INCLUDE_PATH); $response = $client->UploadToServer($filename, "test_user", $file); print_r($response); $transport->close(); } catch (TException $tx) { print 'TException: ' . $tx->getMessage() . "\n"; }
* specific language governing permissions and limitations * under the License. */ use Thrift\Protocol\TBinaryProtocol; use Thrift\Transport\TSocket; use Thrift\Transport\THttpClient; use Thrift\Transport\TPhpStream; use Thrift\Transport\TBufferedTransport; use Thrift\Exception\TException; try { /* if (array_search('--http', $argv)) { $socket = new THttpClient('localhost', 8080, '/php/PhpServer.php'); } else { $socket = new TSocket('localhost', 9090); } */ $socket = new TSocket('sysnet91.sysnet.ucsd.edu', 10030); $transport = new TBufferedTransport($socket, 1024, 1024); //$transport = new TBufferedTransport(new TPhpStream(TPhpStream::MODE_R | TPhpStream::MODE_W));; $protocol = new TBinaryProtocol($transport); $client = new \TrustedBridge\TrustedBridgeClient($protocol); $transport->open(); //$file = fopen("login.html", "rb"); $file = file_get_contents('img/loading.gif', FILE_USE_INCLUDE_PATH); $response = $client->UploadToServer("loading.gif", "early", $file); print_r($response); $transport->close(); } catch (TException $tx) { print 'TException: ' . $tx->getMessage() . "\n"; }