Created
November 22, 2012 19:40
-
-
Save agustinhaller/4132659 to your computer and use it in GitHub Desktop.
booking [hotels]
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var retailers_urlGet = "http://booking.com"; | |
// Lets get retailers from backend API | |
appAPI.request.get(retailers_urlGet, | |
function(response, responseHeaders) | |
{ | |
// Need to get these params from the response | |
var src = $(response).find("input[name=src]").val(), | |
error_url = $(response).find("input[name=error_url]").val(), | |
dcid = $(response).find("input[name=dcid]").val(), | |
sid = $(response).find("input[name=sid]").val(), | |
si = $(response).find("input[name=si]").val(), | |
// Param needed to get dest_id | |
aid = $(response).find("input[name=aid]").val(), | |
// Search string | |
ss = "Miami Beach", | |
checkin_monthday = "21", | |
checkin_year_month = "2012-12", | |
checkout_monthday = "28", | |
checkout_year_month = "2012-12", | |
org_nr_rooms = "1", | |
org_nr_adults = "2", | |
org_nr_children = "0", | |
group_adults = "2", | |
group_children = "0", | |
city_url = "http://www.booking.com/autocomplete?lang=en&aid="+aid+"&term="+ss; | |
debugger; | |
// Before we can get hotels data, we need dest_id param | |
appAPI.request.get(city_url, | |
function(response, responseHeaders) | |
{ | |
var city_data = JSON.parse(response), | |
dest_type = "city", | |
dest_id = city_data.city[0].dest_id, | |
query_url = "http://www.booking.com/searchresults.html?src="+src+"&error_url="+error_url+"&dcid="+dcid+"&sid="+sid+"&si="+si+"&ss="+ss+"&checkin_monthday="+checkin_monthday+"&checkin_year_month="+checkin_year_month+"&checkout_monthday="+checkout_monthday+"&checkout_year_month="+checkout_year_month+"&org_nr_rooms="+org_nr_rooms+"&org_nr_adults="+org_nr_adults+"&org_nr_children="+org_nr_children+"&group_adults="+group_adults+"&group_children="+group_children+"&dest_type="+dest_type+"&dest_id="+dest_id; | |
debugger; | |
// Now that we have these params, we need to get the data | |
appAPI.request.get(query_url, | |
function(response, responseHeaders) | |
{ | |
debugger; | |
console.log(response); | |
}, | |
function(e) | |
{ | |
console.log('Unable to get url ' + retailers_urlGet); | |
} | |
); | |
}, | |
function(e) | |
{ | |
console.log('Unable to get url ' + retailers_urlGet); | |
} | |
); | |
}, | |
function(e) | |
{ | |
console.log('Unable to get url ' + retailers_urlGet); | |
} | |
);// END CORS CALL |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment