Well here is the API I'm trying to use: http://www.hotelscombined.com/api/LiveRates.asmx?op=HotelSearch
Here is the code I've tried:
$client = new SoapClient('http://www.hotelscombined.com/api/LiveRates.asmx?WSDL');
echo '<pre>'; var_dump($client->__getFunctions()); echo '</pre><br /><br /><br />';
//since the above line returns the functions I am assuming everything is fine but until this point
try
{
$client->__soapCall('HotelSearch',
array(
'ApiKey' => 'THE_API_KEY_GOES_HERE', // note that in the actual code I put the API key in...
'UserID' => session_id(),
'UserAgent' => $_SERVER['HTTP_USER_AGENT'],
'UserIPAddress' => $_SERVER['REMOTE_ADDR'],
'HotelID' => '50563',
'Checkin' => '07/02/2009',
'Checkout' => '07/03/2009',
'Guests' => '2',
'Rooms' => '1',
'LanguageCode' => 'en',
'DisplayCurrency' => 'usd',
'TimeOutInSeconds' => '90'
)
);
}
catch (Exception $e)
{
echo $e->getMessage();
}
Anywho this throws an exception and echos the following:
Server was unable to process request. ---> Object reference not set to an instance of an object.
NOTE: I've never used SOAP before so it's possible I'm just doing something fundamentally wrong, even a small tip to get me in the right direction would be hugely appreciated
Tom Haigh suggested wrapping the values in another array which seems to be returning the same error message: (I always tried changing integers to be in integer form and the same with dates)
try
{
$client->__soapCall('HotelSearch',
array('request' =>
array(
'ApiKey' => 'THE_API_KEY_GOES_HERE', // note that in the actual code I put the API key in...
'UserID' => session_id(),
'UserAgent' => $_SERVER['HTTP_USER_AGENT'],
'UserIPAddress' => $_SERVER['REMOTE_ADDR'],
'HotelID' => '50563',
'Checkin' => '2009-07-02',
'Checkout' => '2009-07-03',
'Guests' => 2,
'Rooms' => 1,
'LanguageCode' => 'en',
'DisplayCurrency' => 'usd',
'TimeOutInSeconds' => 90
) )
);
}
catch (Exception $e)
{
echo $e->getMessage();
}