In this recipe, we will quickly look at how you can build an easy webpage using PHP to access the Orchestrator REST API.
We will make our life a bit easier and use a bit of help with PHP and REST. We will use Nate Good's HTTPFUL, which you can find at http://phphttpclient.com/ .
You need to download the following file, httpful.phar
, from his website and place it in the same directory as your script.
You also need a Webserver that uses PHP and has cURL activated. I used LAMP stack from Turnkey https://www.turnkeylinux.org/lampstack . See the There's more section for a fast how-to.
This is a quick intro only:
callWorkflow.php
<?php include('./httpful.phar'); $usr = '[email protected]'; $pwd = 'What4Ever'; $vroServer = '192.168.220.12:8281'; // Example Workflow "07.01 Access via PowerShell" $wfid = '48e10dcf-998c-4db7-b93d-144678e15368'; // URL for the request $uri = "https://{$vroServer}/vco/api/workflows/{$wfid}/executions"; $response = HttpfulRequest::post($uri) // use post ->sendsJson() //conent-typ:applicalion/json ->basicAuth($usr,$pwd) //use basic Authentication ->body("{}") //empty jsonboady ->withoutStrictSsl() //ignore SSL certs ->send(); //send it off //get the Associative array out of the response headers $location=$response->headers; //get the location for the workflow execution echo $location[location]; ?>
http://[ip]/ callWorkflow.php
.Using PHP mostly employs the same method as using PowerShell or the Swagger UI. You post a request, you get a response, you parse the response.
Using this as a stepping stone, you can now develop your own web services for Orchestrator. The full HTTPFUL document can be found here: http://phphttpclient.com/docs/class-Httpful.Request.html
Please have a look at the recipe Turning strings into objects in Chapter 6, Advanced Programming, to understand how to create an object out of a string.
Here is how to get the Turnkey LAMP ready to rumble in some short steps:
https://[ip] :12320
.apt-get update apt-get install curl libcurl3php5-curl mv /etc/php5/mods-available/xcache.ini /etc/php5/mods- available/xcache.ini.OLD
.php
script to /var/www
and call it directly with http://[ip]/[scipt.php]
. There is also a file manager in the web console, https://[ip]:12321/filemin/
.