TalkPHP

TalkPHP (http://www.talkphp.com/forums.php)
-   General (http://www.talkphp.com/general/)
-   -   Send Request in Form, Get XML Back in Variable, Compare and Send Again... (http://www.talkphp.com/general/5859-send-request-form-get-xml-back-variable-compare-send-again.html)

buildakicker 05-03-2011 09:38 PM

Send Request in Form, Get XML Back in Variable, Compare and Send Again...
 
Hello all,

I have been digging away at this for a couple days, but am not getting any closer to a solution...

I have a url (domain/parse.php) that I send some form data to and get a XML response on the page, in the body. From my form on domain2/form.php, I would like to get that response into a variable and pass it to another little function to compare the data. I am striking out at getting the XML from the parse.php page...

Any ideas or thoughts on how to get this?

tony 05-04-2011 01:20 PM

you can use the curl library:
php Code:
//in domain2/form.php

//Initialize the Curl session
$ch = curl_init();

//Set curl to return the data instead of printing it to the browser.
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

//Set the URL
curl_setopt($ch, CURLOPT_URL, "http://domain/parse.php");

//Execute the fetch
$data = curl_exec($ch);

//Close the connection
curl_close($ch);

//then you can handle the XML
$xml = new SimpleXMLElement($data);

buildakicker 05-05-2011 07:34 PM

Thanks for the reply. I have gotten it to work with FSOCKOPEN. We don't have CURL on the PHP instal, but that was one of my initial thoughts... Thanks again for a well writen out example.

tony 05-05-2011 08:10 PM

Great! my knowledge in socket programming has been dwindling down... (need to retry that) So kudos for you.

But you can also use streams, like using a combination of file or file_get_contents with stream contexts (stream_context_create).


All times are GMT. The time now is 04:28 AM.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0