Note that there are some explanatory texts on larger screens.

plurals
  1. POHaving trouble getting my head around SOAP in PHP
    primarykey
    data
    text
    <p>Well here is the API I'm trying to use: <a href="http://www.hotelscombined.com/api/LiveRates.asmx?op=HotelSearch" rel="nofollow noreferrer">http://www.hotelscombined.com/api/LiveRates.asmx?op=HotelSearch</a></p> <p>Here is the code I've tried:</p> <pre><code>$client = new SoapClient('http://www.hotelscombined.com/api/LiveRates.asmx?WSDL'); echo '&lt;pre&gt;'; var_dump($client-&gt;__getFunctions()); echo '&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;'; //since the above line returns the functions I am assuming everything is fine but until this point try { $client-&gt;__soapCall('HotelSearch', array( 'ApiKey' =&gt; 'THE_API_KEY_GOES_HERE', // note that in the actual code I put the API key in... 'UserID' =&gt; session_id(), 'UserAgent' =&gt; $_SERVER['HTTP_USER_AGENT'], 'UserIPAddress' =&gt; $_SERVER['REMOTE_ADDR'], 'HotelID' =&gt; '50563', 'Checkin' =&gt; '07/02/2009', 'Checkout' =&gt; '07/03/2009', 'Guests' =&gt; '2', 'Rooms' =&gt; '1', 'LanguageCode' =&gt; 'en', 'DisplayCurrency' =&gt; 'usd', 'TimeOutInSeconds' =&gt; '90' ) ); } catch (Exception $e) { echo $e-&gt;getMessage(); } </code></pre> <p>Anywho this throws an exception and echos the following:</p> <pre><code>Server was unable to process request. ---&gt; Object reference not set to an instance of an object. </code></pre> <p>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</p> <p>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)</p> <pre><code>try { $client-&gt;__soapCall('HotelSearch', array('request' =&gt; array( 'ApiKey' =&gt; 'THE_API_KEY_GOES_HERE', // note that in the actual code I put the API key in... 'UserID' =&gt; session_id(), 'UserAgent' =&gt; $_SERVER['HTTP_USER_AGENT'], 'UserIPAddress' =&gt; $_SERVER['REMOTE_ADDR'], 'HotelID' =&gt; '50563', 'Checkin' =&gt; '2009-07-02', 'Checkout' =&gt; '2009-07-03', 'Guests' =&gt; 2, 'Rooms' =&gt; 1, 'LanguageCode' =&gt; 'en', 'DisplayCurrency' =&gt; 'usd', 'TimeOutInSeconds' =&gt; 90 ) ) ); } catch (Exception $e) { echo $e-&gt;getMessage(); } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload