h_antar2000 Posted November 7, 2007 Share Posted November 7, 2007 Hi everybody,I want to send a request to a server to obtian from this server hotel's rate. I will try to explain more, of cours you know all online booking hotels site, I have a dealy with a site he gives me a user name and passowrd like this <username>Hantar</username> <passord>anypass</passord> and also gives me all his schema files and xml files but the data is stored in CSV files except hotel rates as I should obtian it through XML request on fly. So would you pls advise how could I do it ?I appreciate your help... Link to comment Share on other sites More sharing options...
boen_robot Posted November 7, 2007 Share Posted November 7, 2007 From your server, by using an S3L available to you, perform the request to the remote server, providing credidentials as needed. Or in other words - create a new pre-programmed browser.In PHP, you can do that with the HTTP extension and more precisely, the HttpRequest and HttpMessage classes.Once you obtain the XML file, you can use whatever method you like to process it. You may use the schema to validate the incoming request, as to ensure that the response is with right format (i.e. if they change it, or if the response has been altered somehow, you could degrade gracefully). Link to comment Share on other sites More sharing options...
h_antar2000 Posted November 7, 2007 Author Share Posted November 7, 2007 From your server, by using an S3L available to you, perform the request to the remote server, providing credidentials as needed. Or in other words - create a new pre-programmed browser.In PHP, you can do that with the HTTP extension and more precisely, the HttpRequest and HttpMessage classes.Once you obtain the XML file, you can use whatever method you like to process it. You may use the schema to validate the incoming request, as to ensure that the response is with right format (i.e. if they change it, or if the response has been altered somehow, you could degrade gracefully). Many thanks for your reply robot, but kindly note that I'm ASP & PHP programer but still bigeners at XML so pls clarify what do you mean by S3L? and would you give me an example page how to obtain the data on fly like display all countries list for example Link to comment Share on other sites More sharing options...
boen_robot Posted November 7, 2007 Share Posted November 7, 2007 Many thanks for your reply robot, but kindly note that I'm ASP & PHP programer but still bigeners at XML so pls clarify what do you mean by S3L? and would you give me an example page how to obtain the data on fly like display all countries list for exampleI wish I didn't had to say that every time... just look at my signature.You can view sample HTTP requests within the documentation that I gave a link to. Here's a simplified version on one of them:<?php$r = new HttpRequest('http://example.com/feed.rss', HttpRequest::METH_GET);try { $r->send(); if ($r->getResponseCode() == 200) { echo 'The body of the returned document is:<pre>' . htmlentities($r->getResponseBody()) . '</pre>'; }} catch (HttpException $ex) { echo 'There was an error during the requst: ' . $ex;}?> This is of course a really basic example just to get the idea. But you can send POST data as well, so if the service requires you to, you can send an XML document in the POST body containing your user name and password, and then you'll fetch the response in a similar fashion to what is used here. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.