list jobs using api 2.0

Forum for users and developers of Bullhorn's Webservices API suite

Moderators: StaffingSupport, s.emmons, BullhornSupport

Post Reply
aap3
User
Posts: 7
Joined: Mon Oct 03, 2011 10:01 am

list jobs using api 2.0

Post by aap3 » Mon Oct 03, 2011 10:23 am

I am new to Bullhorn and want to be able to list the jobs we are advertising.
I have used BroadBean befoe but they "POST" the jobs to our site and we can then use that data to display them.

I have looked through your documentation and from what I have seen all the code samples are for the older API.
I found this page for PHP samples: http://developer.bullhorn.com/Getting_S ... es_and_PHP
but then in the code it says it is the old API and to look at the getting started page:

http://developer.bullhorn.com/getting_started

which then links back to the previos page.

I then found this: http://developer.bullhorn.com/doc/version_2-0/
Which has no examples for PHP or any reference on how to list jobs.

I really need some help to be able to list the jobs we have.

Please Help

k.pham
User
Posts: 21
Joined: Thu Jun 24, 2010 5:13 pm

Re: list jobs using api 2.0

Post by k.pham » Mon Oct 03, 2011 2:57 pm

Hi aap3,

The first step you need to do is to start a session with api 2.0 and return an API_Current session.

Code: Select all

// To run this code, you will need a valid username, password, and API key.
$username = "";
$password = "";
$apiKey = "";
		
// Start a new session
$session_request = new stdClass();
$session_request->username = $username;
$session_request->password = $password;
$session_request->apiKey = $apiKey;
$API_session = $BHclient->startSession($session_request);
$API_currentSession = $API_session->return->session;
In 1.1, to return the current session, you can use this line:
$API_currentSession = $API_session->return;

In 2.0, make sure you use:
$API_currentSession = $API_session->return->session;

Please refer to the article below to see how you make a "query" call (which will returns ids) and use a "find" or "findMultiple" call which takes ids and returns DTO's.
http://developer.bullhorn.com/Getting_S ... es_and_PHP

Let me know if that helps.
-Khanh.

aap3
User
Posts: 7
Joined: Mon Oct 03, 2011 10:01 am

Re: list jobs using api 2.0

Post by aap3 » Tue Oct 04, 2011 7:35 am

Thanks for the help.

I have changed the code as you suggested in the getting started php file but the example does not work.
have I chanegd the top aprt correctly:

Code: Select all

$params = array(
			'trace' => 1,
			'soap_version' => SOAP_2_0);
		$BHclient = new SoapClient("http://api.bullhornstaffing.com/webservices-2.0/?wsdl",$params);
Also I cannto see how to get a list of jobs. I think I hneed to use the JobOrder entity but then which api do I need to use to do so?

aap3
User
Posts: 7
Joined: Mon Oct 03, 2011 10:01 am

Re: list jobs using api 2.0

Post by aap3 » Fri Oct 07, 2011 7:20 am

OK I have managed to figure out how to list the jobs it was because it needed the distict value set eg: 'distinct' => false,
But nowhere in the documentation does it state this or provide any examples, I only found this out as I saw a post on the forum by someone else.

Now I am having problems showing one job using jobOrderID.
I have tried using it in the Where clause like this:

Code: Select all

$query_array =
		array(
		'distinct' => false,
		'entityName' => 'JobOrder',
		'maxResults' => 20,
		'where' => 'isOpen=1 AND type=2 AND jobOrderID=1',
		'parameters' => array()
		);
but that fails.

I have also tried passing the id into find() and findMultiple() but there is a problem with the type casting like this post: http://supportforums.bullhorn.com/viewt ... der#p38101
I do not have NuSoap so cannot use soapval

Please cand you help.

k.pham
User
Posts: 21
Joined: Thu Jun 24, 2010 5:13 pm

Re: list jobs using api 2.0

Post by k.pham » Fri Oct 21, 2011 12:42 pm

Say i want to return the DTO for job 5107910, i have to convert the id to a SoapVar


$id = new SoapVar('5107910', XSD_INTEGER,"int","http://www.w3.org/2001/XMLSchema");

$API_request_find_operation = array(
'session' => $API_currentSession,
'entityName' =>'JobOrder',
'id' => $id
);

try {
$API_response_find_operation = $BHclient->find($API_request_find_operation);
}
catch (SoapFault $fault) {
var_dump($BHclient->__getLastRequest());
die($fault->faultstring);
}

Post Reply