Hi i have a problem with the curl. I watched an old post Remote Login not Working With Curl, but it not work. I followed baba’s advice but the code enter in the if statement. Sorry for my bad english. Can anyone help me?
This is the code:
$url="http://hipfile.com/";
$urllog="http://hipfile.com/login.html";
$postdata = "login=bnnoor&password=########&op=login";
$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt ($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6");
curl_setopt ($ch, CURLOPT_TIMEOUT, 60);
curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_REFERER, $urllog);
curl_setopt ($ch, CURLOPT_POSTFIELDS, $postdata);
curl_setopt ($ch, CURLOPT_POST, 1);
$result = curl_exec ($ch);
if (!$result) {
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch); // make sure we closeany current curl sessions
die($http_code.' Unable to connect to server. Please come back later.');
}
echo $result;
curl_close($ch);
You have cookies off for starters. It seems like the site may require them when you login.
The following function is pretty handy for me, the verbose option will display detailed curl
errors and the ‘post’ option can be set to a post string or an associative array of values
with the key being the variable/field name with it’s value. I also noticed your missing some
post variable from the form on hipfile, this might also be a reason they are denying your
login.
Simple Curl function: