Changes between Version 5 and Version 6 of RemoteJobs


Ignore:
Timestamp:
Jun 18, 2011, 8:42:38 AM (13 years ago)
Author:
davea
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • RemoteJobs

    v5 v6  
    152152
    153153{{{
    154 $ch = curl_init("http://project.edu/job_control.php");
     154$ch = curl_init("https://project.edu/job_control.php");
    155155curl_setopt($ch, CURLOPT_POST, 1);
    156 curl_setopt($ch, CURL_POSTFIELDS, "
     156curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
     157curl_setopt($ch, CURLOPT_POSTFIELDS, "request=
    157158   <batch_estimate>
    158159      <batch>
     
    165166");
    166167$reply = curl_exec($ch);
    167 $r = new SimpleXMLElement($reply);
    168 curl_close($ch);
    169 
    170 if ($r->estimate) {
    171    echo "Estimate: $r->estimate->seconds seconds\n";
     168if (!$reply) die("HTTP op failed\n");
     169$r = simplexml_load_string($reply);
     170if (!$r) die("bad reply: $reply\n");
     171$name = $r->getName();
     172if ($name == 'estimate') {
     173    echo "estimate: ".(string)$r->seconds."\n";
     174} else if ($name == 'error') {
     175    foreach ($r->message as $msg) {
     176        echo "$msg\n";
     177    }
    172178} else {
    173    echo "Error: $r->error->message\n";
     179    die("bad reply\n");
    174180}
    175181}}}