views:

201

answers:

2

Hi,

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?

+1  A: 

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

Robert Cabri
A: 

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.

Shaunak Kashyap