php curl login problem

Posted by user331329 on Stack Overflow See other posts from Stack Overflow or by user331329
Published on 2010-05-03T10:40:22Z Indexed on 2010/05/03 10:58 UTC
Read the original article Hit count: 364

Filed under:
|
<?php
// create a new CURL resource
$file_path = '/mail';
define("COOKIE_FILE", "c:\cookie.txt");
$ch = curl_init();
// set URL and other appropriate options
curl_setopt($ch, CURLOPT_URL, "https://mail.gov.in/iwc/signin");

curl_setopt($ch, CURLOPT_HEADER, 0);
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_COOKIESESSION, TRUE);
session_write_close();
$strCookie = 'PHPSESSID=d095af0e30afc021dd3652734009' . $_COOKIE['PHPSESSID'] . '; path=/mail';
curl_setopt( $ch, CURLOPT_COOKIE, $strCookie );
curl_setopt ($ch, CURLOPT_COOKIEJAR, COOKIE_FILE);
curl_setopt($ch, CURLOPT_COOKIEFILE, COOKIE_FILE);

curl_setopt ($ch, CURLOPT_POST, 1);

curl_setopt ($ch, CURLOPT_POSTFIELDS,'fromLogin=true&domainName=nic.in&username=&password=&button=Sign%20In');

$url = curl_getinfo($ch);

// grab URL and pass it to the browser
$data = curl_exec($ch);
echo $data."<pre>";

echo "<pre>";
print_r($url);

// close CURL resource, and free up system resources
curl_close($ch);
?>

whats wrong with my code why i am not able to login directly in their mail

© Stack Overflow or respective owner

Related posts about curl

Related posts about php