Last active
February 23, 2016 17:44
-
-
Save Paul-Michaud/edb606348470b9b09fad to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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