Hi All,
Seems group is inactive for longtime. Is this something to do with people not interested in php anymore or what? It seems market demand for PHP are also shrinking these days. Anyway lets hope for better.
My question is related to Curl.
I am trying to capture body content of curl request.but it is not working.Following is my code
$post = json_encode(array('vishal'=>1,'vishal2'=>3));
$ch = curl_init($url);
$f = fopen('request.txt', 'a+');
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch,CURLINFO_HEADER_OUT,true);
curl_setopt($ch, CURLOPT_POSTFIELDS,$post); //dumping all data to post content
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_VERBOSE, 1);
curl_setopt($ch, CURLOPT_STDERR,$f); //log header trace in one file
echo $result = curl_exec($ch);
$header_info = curl_getinfo($ch,CURLINFO_HEADER_OUT);
In file, i am able to get details related to header not body content.example below
* About to connect() to localhost port 80 (#0)
* Trying 127.0.0.1... * connected
> POST /test/wsdl/hello_server.php HTTP/1.1
Host: localhost
Accept: */*
Content-Length: 24
Content-Type: application/x-www-form-urlencoded
* upload completely sent off: 24out of 24 bytes
< HTTP/1.1 500 Internal Service Error
< Date: Sun, 23 Feb 2014 07:22:30 GMT
< Server: Apache/2.4.6 (Ubuntu)
< X-Powered-By: PHP/5.5.7-1+sury.org~precise+1
< Content-Length: 278
< Connection: close
< Content-Type: text/xml; charset=utf-8
<
* Closing connection #0
It's sound funny as i am asking for content which my code is preparing but i need content to make debug log. As in Soap client we generally get content details using
$response = $sClient->doHello($params);
echo "REQUEST HEADERS:\n" . $Client->__getLastRequest() . "\n";
Thought there should be same way to get in curl too. Any idea?
Regards,
Vishal