Php curl返回不完整的数据

I am trying to login a site with username and password with php curl.

<?php
$url = 'http://XXXXX.com/login';
$ch = curl_init();
$formFields = array('username' => 'XXXX', 'password' => 'WAO', 'button' => 'Login');
$cookiefile = 'C:/wamp/www/tests/cookies.txt';

curl_setopt($ch, CURLOPT_URL, $url); 
curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
curl_setopt($ch, CURLOPT_HEADER, TRUE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $formFields);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Expect:'));
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookiefile);
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookiefile);

echo $response = curl_exec($ch);
$httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);

But I am not getting complete html in $response. Mean if in browser i am getting 1000 lines in html. In curl I am getting around 350 lines of html.

It was working before but suddenly stopped working.

Any help?

The server could be responding with a meta refresh or an error of some sort. Check the response headers...it's a good place to start

$response = curl_exec($ch);
print_r(curl_getinfo($ch));

You should also be sending your post fields as a string, not an array by using http_build_query()

$formFields = http_build_query( array('username' => 'XXXX', 'password' => 'WAO', 'button' => 'Login'));

If the page you are loading is loading content through Ajax onto the page, you will, obviously have different results. And, the site you mentioned does seem to load content through ajax request(s).

cURL doesn't/can't parse javascript, and hence can't load content through ajax. So, you have no way of getting the exact same content as you would get from a normal-browser.

You can verify the above said statement by comparing cURL's output and browser-with-javascript-disabled's output and finding them to be same.