The new ePO API in version 4.6 is extremely powerful allowing you to interface with ePO in a more powerful fashion. It certainly will not be used by all customers but those more complex/larger customers will appreciate the flexibility. So what kind of things can be done with it? Well, alot. You can read through the documentation for some examples and other threads on this board. One of the trickiest things is deciding how to interface with the API. Our manual talks about Python or a powershell but there are dozens of other possibilities. Python is extremely powerful but a more common way to talk to the API is thru a simple browser. After all, the API is is just sending a URL to ePO and ePO is spitting out results based on the URL being passed to it. Make sure you check out the API Explorer to see what kind of thngs you can create and get the URL formats you need. https://community.mcafee.com/docs/DOC-2931 Here is how to build an HTML Interface to the ePO API
Browser Front End
First you need a web server. We have chosen Linux Ubuntu running Apache and compiled it with PHP and cURL. Apache and PHP are pretty common and cURL is a library that allows you to script the transferring of data with URL syntax, supporting DICT, FILE, FTP, FTPS, HTTP and several other protocols. Most of it is straightforward and can be done within two hours. Once you get the framework in place, the next step is build an HTML interface that calls a php file that will call some cURL commands and send them to ePO for processing.
Buidling the HTML
You need a basic HTML page where the user can interact and enter data or hit a submit button that will call the PHP page. Here we have combined a few different options that will allow the user to search for a PC, query the API help page, apply a tag to a machine and a few others.
Looking at the source of the page we see that each command is just a form that is doing a post and calling a php file. Sometimes you will need to pass a variable to the php page and sometimes you are just hitting Submit with no data being passed. If you are passing a variable make sure its being stored somewhere as shown below. Heres the source of the first command.
<P>Enter PC name, IP address or Username to search for.(Try epo, share, or
<TD width="56%" class=box1>
<FORM id=form1 method=post name=form1
action=api-pcsearch.php><LABEL><INPUT size=30 type=text name=searchText>
</LABEL><INPUT id=Submit value=Submit type=submit name=Submit>
Building the PHP page that connects to the API
So now you should have some basic HTML that is calling some php files when you hit the Submit button. So what does the php page look like? If there is a variable passed by the form we will place it in $myvar. The $url variable is the url we want to pass to ePO via cURL. We then need to authenticate to ePO with a username and password with some cURL commands and some other basic options for cURL. Most of the defaults added below are needed. Also have cURL pass your variable to ePO as needed. I have also included some debug lines that are commented out so you can troubleshoot.
// Retrieve the hidden form variable that was entered in the HTML form. The variable that is passed from
// HTML to here is placed in $myvar. If not passing a variable then comment out $myvar
$myvar = $_POST['searchText'];
// The url variable is the get command passed to ePO
$url = "https://172.23.130.202/remote/core.executeQuery?";
$ch = curl_init(); // initialize curl handle
curl_setopt($ch, CURLOPT_URL,$url); // set url to post to
// The next line passes epo credentials for authentication to epo server
curl_setopt($ch, CURLOPT_USERPWD, "epouseraccount:password");
curl_setopt($ch, CURLOPT_FAILONERROR, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);// allow redirects
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); // return into a variable
curl_setopt($ch, CURLOPT_TIMEOUT, 3); // times out after 4s
curl_setopt($ch, CURLOPT_POST, 0); // set POST method which is GET
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); // this avoids failures if cert is not valid
curl_setopt($ch, CURLOPT_POSTFIELDS, "queryId=$myvar"); // add POST fields
$result = curl_exec($ch); // run the whole process
//Uncomment the next 3 lines for error analysis
//echo "\n\ncURL error number:" .curl_errno($ch);
//echo "\n\ncURL error:" . curl_error($ch);
echo nl2br($result); //nl2br adds line breaks to result
If all goes well you should get a page that looks like this when you do a search for a machine.
Of course this page is pretty plain. You can add some HTML, a nice logo and stylesheets to pretty it up but you should get the point. Below the sample php files and the HTML page used for this demo so you can get started.