#! /usr/bin/env php
$xml, 'seq_file' => "@$file");
} else {
$fields = "request=$xml";
}
if (!curl_setopt($ch, CURLOPT_POSTFIELDS, $fields)) {
die("curl_setopt failed\n");
}
$reply = curl_exec($ch);
if (!$reply) return array(null, "HTTP error");
$r = simplexml_load_string($reply);
if (!$r) return array(null, "Can't parse reply XML:
".htmlentities($reply)."
");
return array($r, null);
}
function handle_submit() {
global $argc, $argv;
if ($argc != 4) usage();
if (!is_file($argv[2])) die("seq file missing");
$auth = $argv[3];
$req_xml = "
submit
$auth
";
list($reply, $errmsg) = do_http_op($req_xml, $argv[2]);
if ($errmsg) die("Error: $errmsg\n");
echo "batch ID: ".(int)$reply->batch_id."\n";
}
function handle_get_output() {
global $argc, $argv;
if ($argc != 4) usage();
$batch_id = $argv[2];
$auth = $argv[3];
$req_xml = "
get_output
$batch_id
$auth
";
list($reply, $errmsg) = do_http_op($req_xml);
if ($errmsg) die("Error: $errmsg\n");
echo (string)$reply->url, "\n";
}
if ($argc < 2) usage();
switch ($argv[1]) {
case "submit": handle_submit(); break;
case "get_output": handle_get_output(); break;
default: usage();
}
?>