Having trouble getting my head around SOAP in PHP

后端 未结 3 887
挽巷
挽巷 2020-12-17 05:51

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          


        
3条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-17 06:13

    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);
    

提交回复
热议问题