Skip to content

Instantly share code, notes, and snippets.

@checco
Last active October 17, 2016 08:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save checco/c0a6540d46eb163f82bf4906aa535aef to your computer and use it in GitHub Desktop.
Save checco/c0a6540d46eb163f82bf4906aa535aef to your computer and use it in GitHub Desktop.
OTA_HotelAvailRQ with class NET:Http
require 'uri'
require 'openssl'
require 'net/http'
url = URI("https://www.hostelspoint.com/xml/xml.php")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
request = Net::HTTP::Post.new(url)
request["content-type"] = 'application/x-www-form-urlencoded'
request["cache-control"] = 'no-cache'
request.body = 'OTA_request=<?xml version="1.0" encoding="UTF-8"?> <OTA_HotelAvailRQ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.opentravel.org/OTA/2003/05" xsi:schemaLocation="http://www.opentravel.org/OTA/2003/05OTA_PingRQ.xsd" TimeStamp="2016-05-09T16:57:54+02:00" Target="Test" Version="1.006" PrimaryLangID="en" EchoToken="OTA_HotelAvailRQ5730a57263a19" RequestedCurrency="EUR" AllowPartialAvail="false"> <POS> <Source> <RequestorID ID="USER" MessagePassword="PASSWORD"/> </Source> </POS> <AvailRequestSegments> <AvailRequestSegment> <HotelSearchCriteria> <Criterion> <StayDateRange Start="2016-10-19" End="2016-10-21"/> <HotelRef HotelCode="HOTELCODE"/> </Criterion> </HotelSearchCriteria> </AvailRequestSegment> </AvailRequestSegments> </OTA_HotelAvailRQ>'
response = http.request(request)
puts response.read_body
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment