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
One thing that drove me crazy for days - double-check the names of your array elements (ApiKey, UserId, etc). Make sure the case is correct also. I wasted hours on a on an incorrectly cased 'm'.
Try making a PHP object, then referencing that object in your soap call.
class HotelRequest {
public $apiKey;
public $userID;
public $userAgent;
public $userIPAddress;
public $hotelID;
public $checkin;
public $checkout;
public $guests;
public $rooms;
public $languageCode;
public $displayCurrency;
public $timeOutInSeconds;
}
//set the values of the object...
$hotelRequestObject = new HotelRequest();
$hotelRequestObject->apiKey = "API_KEY";
//etc...
$client = new SoapClient('http://www.hotelscombined.com/api/LiveRates.asmx?WSDL',
array("classmap" => array("HotelSearchRequest" => "HotelRequest")));
$result = $client->HotelSearch($hotelRequestObject);
var_dump($result);
I find when using PHP's SOAP implementation you end up wrapping everything up in more arrays than you think you need.
The below example seems to work, but also you need to format your date values correctly before it will work. I'm not sure of the best way of doing this - it might be that you can pass an Integer representing UNIX time and PHP will convert it for you.
$client->__soapCall('HotelSearch',
array(
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' => '07/02/2009',
'Checkout' => '07/03/2009',
'Guests' => '2',
'Rooms' => '1',
'LanguageCode' => 'en',
'DisplayCurrency' => 'usd',
'TimeOutInSeconds' => '90'
)
)
)
);