Adlogic Webservice API


Posted By: Thomas Shaw, 7:30am Monday 01 November 2010

Adlogic has released a webservice API which has opened up their internal system for 3rd party developers to build websites and applications from. They have also released a number of pre-built scripts allowing recruiters/employers to easily integrate their job board with the new webservice API.

I've been lucky enough to be using and testing the new API for the past few months now and it's very easy to pull client job ads in real time instead of waiting for a XML file to be send through. Besides building a script to search and view jobs. More functions are expected to be added to the webservice including subscribing users to job alerts and posting job applications back into Adlogic.

In this example I will show you how to display a requested job ad via the system. You will need to understand SOAP and XML. SOAP is the communication method for accessing a webservice.

First we need to understand the types of requests Adlogic has available. We are going to use "createXMLToViewAd" with a test jobAdId and it will return the job ad in a XML structure. In that example below we will look at the SOAP envelope calls.


SOAP Request




SOAP Response




Now we understand what the return XML looks like, we can now script the request. In this example I am writing it in PHP. PHP 5 includes inbuilt SOAP and XML classes.


PHP Code
<?PHP // set webservice API $wsdl_url = 'http://www.adlogic.com.au/AdlogicJobPortalService?WSDL'; // connect to the webservice $getJobDetails = new SoapClient($wsdl_url, array('trace' => 1)); // pass in the parameters $searchParams = array('jobAdId' => 3968303); // call the method $wsResults = $getJobDetails->createXMLToViewAd($searchParams); // return results $jobreturn = $wsResults->return; // read the XML and design the job ad $xmlRaw = iconv("UTF-8","UTF-8//IGNORE",$jobreturn); $xml = simplexml_load_string($xmlRaw); // check string length of each bulletpoint. If yes, display if ((strlen($xml->BulletPoints->BulletPoint[0]) > 0) || (strlen($xml->BulletPoints->BulletPoint[1]) > 0) || (strlen($xml->BulletPoints->BulletPoint[2]) > 0)) { $bulletpoints = '<ul>'; } if (strlen($xml->BulletPoints->BulletPoint[0]) > 0) { $bulletpoints .= '<li>'.$xml->BulletPoints->BulletPoint[0].'</li>'; } if (strlen($xml->BulletPoints->BulletPoint[1]) > 0) { $bulletpoints .= '<li>'.$xml->BulletPoints->BulletPoint[1].'</li>'; } if (strlen($xml->BulletPoints->BulletPoint[2]) > 0) { $bulletpoints .= '<li>'.$xml->BulletPoints->BulletPoint[2].'</li>'; } if ((strlen($xml->BulletPoints->BulletPoint[0]) > 0) || (strlen($xml->BulletPoints->BulletPoint[1]) > 0) || (strlen($xml->BulletPoints->BulletPoint[2]) > 0)) { $bulletpoints .= '</ul>'; } echo '<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <style type="text/css"> body, td, p { font-size: 12px; font-family: Arial, Helvetica, sans-serif; color: #000000; } </style> </head> <body> <table width="460px" style="border: 1px solid #000000;" cellpadding="0" cellspacing="0"> <tr> <td><div style="margin:20px; font-size:18pt; line-height:normal">'.$xml->JobTitle.'</div> <div style="margin:20px;">'.$bulletpoints.$xml->JobDescription.'</div> <div style="margin:20px;"><a href="'.$xml->Enquiry->ApplicationURL.'"><strong>APPLY NOW</strong> </a></div></td> </tr> </table> </body> </html>'; ?>
PHP Output