HI,
I am able to login into the site using php and curl. but when i try to read the data after logging in it shows string(0) “” if CURLOPT_RETURNTRANSFER enabled and when disabled it shows bool(true). I dont understand where exactly i am going wrong…
any help is really appreciated
heres code
$cookie_file_path = "C:\\Apache2\\htdocs\\test.txt";
//$fp = fopen($cookie_file_path,'wb');
//fclose($fp);
$agent = "Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/3.6.0";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,"https://kinray.com/redirector1/weblink.jsp");
curl_setopt($ch, CURLOPT_USERAGENT, $agent);
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_fie_path);
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file_path);
curl_setopt($ch, CURLOPT_REFERER, "http://www.google.com");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
//Do not print anything now.
//curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_POSTFIELDS, "custId=XXXXX&passWord=YYYYY");
$html = curl_exec($ch);
var_dump(urlencode($html));
curl_close();
$ch1 = curl_init();
curl_setopt($ch1, CURLOPT_URL,"https://kinray.com/weblink2/search/categories.do?scrollType=&code=&alwaysCustomerNumber=023987");
curl_setopt($ch1, CURLOPT_COOKIEFILE, $cookie_fie_path);
curl_setopt($ch1, CURLOPT_COOKIEJAR, $cookie_file_path);
curl_setopt($ch1, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch1,CURLOPT_HTTPGET,true);
//curl_setopt($ch1, CURLOPT_FOLLOWLOCATION, 1);
//curl_setopt($ch1, CURLOPT_HEADER, 1);
curl_setopt($ch1, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch1, CURLOPT_SSL_VERIFYHOST, 0);
$html2 = curl_exec($ch1);
curl_close();
echo "<hr>";
var_dump( $html2);
Any clue where am i going wrong?
should these variables be different?
It may be that your cookies aren’t being stored/retrieved properly.
httpRequest Class Example (short form static constructors):
you can easily get to the response body by accessing the body property (
$loggedInPage->body, for example) from there. Let me know if this works for you.EDIT: Sample Response