我正在开展网站项目,以使用旅行社的网络服务。 未来的网站将是一个旅行时代,其中包含与源网站相同的酒店,房间等。 所以,我需要连接到他们的API,发送我的网站中的genrerated XML文件,然后收到响应。
这就是我所拥有的:
旅行社api地址:
http://api.xxx.net/API/API.asmx
方法
GetHotels :您的seacrh标准的可用房间的方法列表。
MakeBooking :这些方法会为您的预订请求创建预订。
GetBookingDetail :这些方法可以为您的预订提供详细信息。
ASP.Net示例代码
public void GetHotels()
{
API.PASSENGER[] pass = new API.PASSENGER[3];
pass[0] = new API.PASSENGER();
pass[0].PASSTYPE = "ADT";
pass[0].FIRSTNAME = "TEST";
pass[0].LASTNAME = "test last name";
pass[1] = new API.PASSENGER();
pass[1].PASSTYPE = "ADT";
pass[1].FIRSTNAME = "test 2";
pass[1].LASTNAME = "test last name";
pass[2] = new API.PASSENGER();
pass[2].PASSTYPE = "CHD";
pass[2].DOB = "16.06.2001";
pass[2].FIRSTNAME = "TEST child";
pass[2].LASTNAME = "test last name";
API.SEARCH_REQUEST rq = new API.SEARCH_REQUEST();
rq.AGENTINFO = new API.AGENT_INFO();
rq.AGENTINFO.AGENT_ID = "agent login";
rq.AGENTINFO.AGENT_PWD = " agent pass";
rq.TOWNCODE = "";
rq.CHECKINDATE = "02.09.2014";
rq.CHECKOUTDATE = "08.09.2014";
rq.HOTELCODE = "";
rq.LANGUAGECODE = "TRK";
rq.PASSENGERLIST = pass;
Response.Write(rq.CHECKINDATE);
Response.Write(rq.CHECKOUTDATE);
API.API api = new API.API();
API.SEARCH_RESPONSE[] test = api.GetHotels(rq);
for (int i = 0; i < test.Length; i++)
{
Response.Write(test[i].ERRORINFO.ToString() + "<br>");
Response.Write(test[i].HOTELNAME + "<br>");
Response.Write(test[i].HOTELPICTURE + "<br>");
Response.Write(test[i].HOTELSHORTINFO + "<br>");
Response.Write(test[i].PLACECODE + "<br>");
Response.Write(test[i].PLACENAME + "<br>");
Response.Write(test[i].PRODUCTKEY + "<br>");
Response.Write(test[i].ROOMNAME + "<br>");
Response.Write(test[i].ROOMPRICE + "<br>");
Response.Write(test[i].CHECKINDATE + "<br>");
Response.Write(test[i].CHECKOUTDATE + "<br>");
Response.Write(test[i].ROOMNAME + "<br>");
Response.Write("<hr/>");
}
}
public void MakeBooking()
{
API.API api = new API.API();
API.PASSENGER[] pass = new API.PASSENGER[3];
pass[0] = new API.PASSENGER();
pass[0].PASSTYPE = "ADT";
pass[0].FIRSTNAME = "TEST";
pass[0].LASTNAME = "test last name";
pass[0].DOB = "dfss";
pass[1] = new API.PASSENGER();
pass[1].PASSTYPE = "ADT";
pass[1].FIRSTNAME = "test 2";
pass[1].LASTNAME = "test last name";
pass[1].DOB = "16.03.1983";
pass[2] = new API.PASSENGER();
pass[2].PASSTYPE = "CHD";
pass[2].DOB = "16.06.2001";
pass[2].FIRSTNAME = "TEST child";
pass[2].LASTNAME = "test last name";
API.ROOM_DETAIL[] room = new API.ROOM_DETAIL[1];
room[0] = new API.ROOM_DETAIL();
room[0].CHECKINDATE = "02.09.2014";
room[0].CHECKOUTDATE = "08.09.2014";
room[0].HOTELCODE = "AP";
room[0].PRODUCTKEY = "27-926-27677";
API.BOOKING_REQUEST book = new API.BOOKING_REQUEST();
book.AGENTINFO = new API.AGENT_INFO();
book.CUSTOMERINFO= new API.CUSTOMER();
book.AGENTINFO.AGENT_ID = " agent login ";
book.AGENTINFO.AGENT_PWD = " agent pass";
book.CUSTOMERINFO.ADDRESS = "istanbul plaza";
book.CUSTOMERINFO.CITY = "istanbul";
book.CUSTOMERINFO.COUNTRY = "Turkey";
book.CUSTOMERINFO.EMAIL = "mert@xxx.com";
book.CUSTOMERINFO.FAX = "11111";
book.CUSTOMERINFO.FIRSTNAME = "API";
book.CUSTOMERINFO.LASTNAME = "API";
book.CUSTOMERINFO.PHONE = "222";
book.CUSTOMERINFO.PHONEMOBILE = "532";
book.CUSTOMERINFO.TITLE = "MR";
book.CUSTOMERINFO.ZIP = "34768";
book.LANGUAGECODE = "TRK";
book.PASSENGERLIST = pass;
book.ROOMDETAIL_LIST = room;
API.BOOKING_RESPONSE bookResponse = api.MakeBooking(book);
Response.Write(bookResponse.ERRORINFO + "<br>");
Response.Write(bookResponse.BOOKINGSTATUS + "<br>");
Response.Write(bookResponse.PNR + "<br>");
Response.Write(bookResponse.TOTALCOMISSION + "<br>");
Response.Write(bookResponse.TOTALAMOUNT + "<br>");
}
我不知道如何开始。我真的可以使用一些帮助。
谢谢!
答案 0 :(得分:0)
使用http://api.suaytur.net/API/API.asmx?WSDL中的WSDL,您可以从wsdltophp.com生成相应的包,以确保如何在PHP中构造您的请求,因为每个元素都是具有setter / getters的PHP对象。它使用本机PHP SoapClient类,因此如果您熟悉PHP,您可以轻松快速地了解发送这些请求的人员