Monday, June 20, 2011

Drupal Taleo Integration with SOAPClient

Taleo is a Talent Management System. Many companies use Taleo for the recruitment services. Taleo has an API which can be used to make API calls to fetch data from the Taleo servers. Though there is documentation about the Taleo integration, it is confusing at places and misleading at some.

The following code helps us to fetch job titles and location from the Taleo server. The explanation of each block of code follows next.

try {
  $client = new SoapClient("http://tbe.taleo.net/wsdl/DispatcherAPI.wsdl", array('trace' => true)); 
  $url = $client->__call('getURL', $company_name);
  $clientTaleo = new SoapClient("http://tbe.taleo.net/wsdl/WebAPI.wsdl", array('trace' => true));
  $clientTaleo->__setLocation($url);
  $params = array(
             'in0' => $comp_name,
             'in1' => $user_name,
             'in2' => $password,
  );
  $session =  $clientTaleo->__call('login', $params);
  $params = array(
           'in0' => $session,
           'in1' => array('status' => 'Filled', 'city' => 'Bothell',)
          );
  $jobIds =  $clientTaleo->__call('searchRequisition', $params);
            foreach($jobIds->array->item as $jobid){
              $params = array(
                'in0' => $session,
                'in1' => $jobid->id,
                );

                $job = $clientTaleo->__call('getRequisitionById', $params);
                print $job->title . '  ' . $job->location;
            }  
  
            
} catch (SoapFault $fault) {
            $error = 1;
            print("
            
'Sorry, blah returned the following ERROR: ".$fault->faultcode."-".$fault->faultstring
            );
} 


You need to follow a three step procedure to get any meaningful data from taleo.

1) Access a fixed url to get a local-url for your company : Based on your location you get different urls. This is done for load balancing.
$client = new SoapClient("http://tbe.taleo.net/wsdl/DispatcherAPI.wsdl", array('trace' => true)); 
 $url = $client->__call('getURL', $company_name);

Gives you a url like : https://tbe.taleo.net/NA7/ats/services/rpcrouter
2) Authenticate via the url retrieved from first step to get a session token : This session token changes on every request you make.
$clientTaleo = new SoapClient("http://tbe.taleo.net/wsdl/WebAPI.wsdl", array('trace' => true));
  $clientTaleo->__setLocation($url);
  $params = array(
             'in0' => $comp_name,
             'in1' => $user_name,
             'in2' => $password,
  );
  $session =  $clientTaleo->__call('login', $params);  

3) Use the session token from the second step to invoke the various Taleo API methods.
$params = array(
            'in0' => $session,
            'in1' => $jobid_id,
          );

$job = $clientTaleo->__call('getRequisitionById', $params);
print $job->title . '  ' . $job->location;

2 comments:

  1. Nice article. Is there an api call to get the list of all categories?

    ReplyDelete
  2. Hello,

    I'm building a new PHP Library to access Taleo, you can find it here: https://github.com/Polzme/Taleo

    Feedback is welcome !

    ReplyDelete