Skip to content

Instantly share code, notes, and snippets.

@Paul-Michaud
Last active February 23, 2016 17:44
Show Gist options
  • Save Paul-Michaud/edb606348470b9b09fad to your computer and use it in GitHub Desktop.
Save Paul-Michaud/edb606348470b9b09fad to your computer and use it in GitHub Desktop.
<?php
//Optional parameters hostname + admin_name + authtoken
$argString = urlencode('-hostname '.$hostname.' -admin_name '.$admin_name.'');
$authtoken = urlencode($token);
$fields = array(
'argString' => $argString,
'authtoken' => $authtoken
);
//Build post request
$fields_string='';
foreach($fields as $key=>$value) { $fields_string .= $key.'='.$value.'&'; }
$fields_string = substr($fields_string, 0, -1); //Delete the last &
$runJobURL = $apiURL.$jobId.'/run';
//Job execution
$curlRunJob = curl_init();
curl_setopt($curlRunJob,CURLOPT_URL, $runJobURL);
curl_setopt($curlRunJob,CURLOPT_POST, count($fields));
curl_setopt($curlRunJob,CURLOPT_POSTFIELDS, $fields_string);
curl_setopt($curlRunJob, CURLOPT_RETURNTRANSFER, true); //Don't display curl result
$resultRunJob = curl_exec($curlRunJob);
curl_close($curlRunJob);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment