-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample.php
40 lines (34 loc) · 1.12 KB
/
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
35
36
37
38
39
40
<?php
if($argc<2){
echo "\n usage: php getOTX.php content service\n";
exit;
}
// Setup Defaults
$otx_account = 'otx,otxpass';
$otx_mimetype = "text/html";
// Fill from cli
$otx_content = $argv[1];
$otx_service = ( isset($argv[2])) ? $argv[2] : "wmt";
// Setup data for http query
$url = 'https://es-otx.onelink-poc.com/OneLinkOTX/';
$data = array(
'otx_account' => $otx_account
,'otx_service' => $otx_service
,'otx_mimetype' => $otx_mimetype
,'otx_content' => $otx_content
);
// Setup stream options
$options = array(
'http' => array(
'header' => "Content-type: application/x-www-form-urlencoded\r\n",
'method' => 'POST',
'content' => http_build_query($data),
),
);
// Create stream , get contents
$context = stream_context_create($options);
$result = file_get_contents($url, false, $context);
// Results
echo "\n content:" . $otx_content;
echo "\n translated:" . $result ."\n";
?>