English 中文(简体)
how to capture CURL / XML data with Apache?
原标题:

I m developing a gateway script that needs to send info to another provider s server, and I need to debug the code.

Is there a way, on my own Linux + Apache + PHP server to capture the CURL / XML data from this script?

I know with PHP, that I could see for example the $_POST, $_GET or $_REQUEST data in a script, but with CURL I don t actually get to the http://intranet/capture.php script in my browser - so this doesn t work.

Is there any other way, with a script on the server to capture everything that s passed to the server, and dump it to a database / flat file?

I even tried monitoring /var/logs/http/access_log on the Linux server, but it didn t reveal much

So, how can I see what the CURL script does, exactly, as the server sees it?

问题回答

what you can try is this.

echo htmlentities(file_get_contents( http://intranet/capture.php ));

I m not sure if this is what you mean but it does the same as curl (sort of)

You want to see the output of curl

$ch = curl_init();    // initialize curl handle
curl_setopt($ch, CURLOPT_URL, $url ); // set url to post to
curl_setopt($ch, CURLOPT_FAILONERROR, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);// allow redirects
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); // return into a variable
curl_setopt($ch, CURLOPT_TIMEOUT, 3); // times out after 4s
curl_setopt($ch, CURLOPT_POST, 1); // set POST method
$result = curl_exec($ch); // run the whole process
curl_close($ch);

echo htmlentities($result);

I hope this is what you mean

In this case, you are the client and the provider s server is the server.

Assuming you are running the curl command from the client, all you can get to is what Robert Cabri said.

If you are attempting to look at whats being received by the server, you need to have appropriate access and also need to know what application stack the server is running to serve your request.





相关问题
Using SimplePie with CodeIgniter and XAMPP

I am using CodeIgniter 1.7.2 with XAMPP 1.7.2 on a Windows computer. I am trying to make use of SimplePie. I followed all the instructions I could find: a copy of simplepie.inc is in my applications/...

Multiple Sites with common files

I have developed over 50 sites that all use the exact same files other than CSS and IMAGES, I currently duplicate the files each time I create a new site and upload different css and images. What ...

http server validation

I finish a litle http server, writing from scratch. I would like to be sure that my imlementation is conforme to the HTTP specifications. W3C give us tools for HTML/XML conformance, but i see nothing ...

热门标签