-
Notifications
You must be signed in to change notification settings - Fork 0
/
example.php
executable file
·35 lines (25 loc) · 797 Bytes
/
example.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<?php
require __DIR__ . '/vendor/autoload.php';
use Thrift\Protocol\TBinaryProtocol;
use Thrift\Transport\TFramedTransport;
use Thrift\Transport\TSocketPool;
$messages = array();
$msg1 = new LogEntry();
$msg1->category = 'foo';
$msg1->message = 'foo message';
$messages[] = $msg1;
$msg2 = new LogEntry();
$msg2->category = 'bar';
$msg2->message = 'bar message';
$messages[] = $msg2;
list($host, $port,) = array_slice($argv, 1);
$socket = new TSocketPool(array($host), array(intval($port)));
$transport = new TFramedTransport($socket);
$protocol = new TBinaryProtocol($transport);
$scribeClient = new scribeClient($protocol);
$transport->open();
$resultCode = $scribeClient->Log($messages);
$transport->close();
if ($resultCode == ResultCode::OK) {
echo "messages send success.\n";
}