Ask what controls or functions on PHP can initiate XML requests and get back data. now we need to use PHP to make a flight query and order a program. We contacted a business travel platform, the documents provided by their technology are a submission form. after they are submitted to their server, an XML data is returned, if you want to use PHP controls or functions to initiate XML requests and retrieve data, you will be confused. It is better to have some cases. ------ Solution -------------------- P: determine which controls or functions on PHP can initiate XML requests and obtain the returned data.
Now I want to use PHP for a flight query and ordering procedure. I contacted a business travel platform,
The documentation provided by their technology is a submission form. after it is submitted to their server, an XML data is returned, asking me to use PHP controls or functions to initiate XML requests and retrieve the data back.
I'm confused. please try again. thank you. It is better to have some cases.
------ Solution --------------------
PHP code
Xmldata'; // The xml $ url to be sent = 'http: // localhost/test/getXML. php '; // receive XML address $ header = 'content-type: text/XML'; // Define Content-type as xml $ ch = curl_init (); // initialize curlcurl_setopt ($ ch, CURLOPT_URL, $ url); // Set the link curl_setopt ($ ch, CURLOPT_RETURNTRANSFER, 1); // Set whether to return information curl_setopt ($ ch, CURLOPT_HTTPHEADER, $ header); // Set the HTTP header curl_setopt ($ ch, CURLOPT_POST, 1); // Set it to the POST method curl_setopt ($ ch, CURLOPT_POSTFIELDS, $ xml ); // POST data $ response = Curl_exec ($ ch); // receives the returned information if (curl_errno ($ ch) {// error message print curl_error ($ ch );} curl_close ($ ch); // Close the curl link echo $ response; // display the returned information?>
------ Solution --------------------
Like the upstairs curl, snoopy, fopen, or fsockopen...
Xml can be obtained
Xml parsing
SimpleXML
Read through the usage of these things first, and then you can start the work, very simple things