Hello Masters,
My curl code is written below, but it results in 411 Length Required.
Note that I tested withbut that didnt make any difference, thats why I commented that line off.PHP Code:$hdr[] = "Content-Length: ".$bodyLength."\r\n\r\n";
Please helpPHP Code:$hdr = array();
$hdr[] = "POST /abc/mypage.aspx HTTP/1.1\r\n";
$hdr[] = "Host: mysite.com\r\n";
$hdr[] = "User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:16.0) Gecko/20100101 Firefox/16.0\r\n";
$hdr[] = "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\r\n";
$hdr[] = "Accept-Language: en-US,en;q=0.5\r\n";
$hdr[] = "Accept-Encoding: gzip, deflate\r\n";
$hdr[] = "Connection: keep-alive\r\n";
$hdr[] = "Referer: https://www.mysite.com/abc/mypage.aspx\r\n";
$hdr[] = "Cookie: ASP.NET_SessionId=$ASPSESS\r\n";
$hdr[] = "Content-Type: multipart/form-data; boundry=".$d.$boundary."\r\n";
//$hdr[] = "Content-Length: ".$bodyLength."\r\n\r\n";
$ch = curl_init();
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_POSTFIELDS, $body);
curl_setopt($ch, CURLOPT_URL, "https://www.mysite.com/abc/mypage.aspx");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
curl_setopt($ch, CURLOPT_HEADER, TRUE);
curl_setopt($ch, CURLOPT_HTTPHEADER, $hdr);
curl_setopt($ch, CURLOPT_COOKIEFILE, dirname(__FILE__) . "/cookies.txt");
curl_setopt($ch, CURLOPT_COOKIEJAR, dirname(__FILE__) . "/cookies.txt");
$data = curl_exec($ch);
curl_close($ch);
Regards
ZH



Reply With Quote




Bookmarks