Read content using curl
Using Curl i am sending some post data to a server.This is the Header reponse iam getting
HTTP/1.1 100 Continue HTTP/1.1 200 OK Content-Length: 30 Content-T开发者_开发百科ype: text/html;charset=ISO-8859-1 Server: Microsoft-IIS/7.0 X-Powered-By: Servlet 2.5; JBoss-5.0/JBossWeb-2.1 Set-Cookie: JSESSIONID=XXXXXXXXXXXXXXXXXXXXXXX; Path=/thegateway; Secure P3P: CP="CAO PSA OUR" X-Powered-By: ASP.NET Date: Sat, 22 Jan 2011 00:07:25 GMT
how do i read the rest of the content?
Maybe you forgot to set the CURLOPT_RETURNTRANSFER option in the curl call? When it is set, the content of the response is returned by the curl_exec() function itself.
This is a code from a working project of mine:
$options = array(
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_RETURNTRANSFER => $this->return_content, // return web page
CURLOPT_HEADER => false, // don't return headers, they are processed through callback
CURLOPT_FOLLOWLOCATION => $this->follow_redirects, // follow redirects
CURLOPT_ENCODING => "", // handle all encodings
CURLOPT_USERAGENT => $this->user_agent, // who am i
CURLOPT_CONNECTTIMEOUT => $this->connect_timeout, // timeout on connect
CURLOPT_TIMEOUT => $this->request_timeout, // timeout on response
CURLOPT_BINARYTRANSFER => true,
);
$extraheaders = array();
$res = curl_init( $url );
curl_setopt_array( $res, $options );
$content = curl_exec( $res );
精彩评论