note 20745 added to ref.curl
| From: | php-general at lists dot php dot net | Date: | Mon, 15 Apr 2002 02:23:43 +0000 |
| Subject: | note 20745 added to ref.curl | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-29350@lists.php.net to get a copy of this message | ||
#!/usr/local/bin/php -q
<?php
$id = "xxxx";
$pw = "xxxx";
$LOGINURL = "http://login.daum.net/Mail-bin/login.cgi";
$GETURL = "http://www.daum.net/Mail-bin/mail_list";
$POSTFIELDS = "id=$id&pw=$pw";
function AUTH_SITE_COOKIE_STORE($LOGINURL,$POSTFIELDS)
{
$parseURL = parse_url($LOGINURL);
$ch = curl_init();
curl_setopt($ch, CURLOPT_COOKIEJAR, "$parseURL[host].cookie");
curl_setopt($ch, CURLOPT_URL,"$LOGINURL");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "$POSTFIELDS");
ob_start();
curl_exec ($ch);
ob_end_clean();
curl_close ($ch);
return "$parseURL[host].cookie";
}
function AUTH_SITE_GET($GETURL,$cookieFile)
{
$parseURL = parse_url($GETURL);
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_COOKIEFILE, "$cookieFile");
curl_setopt($ch, CURLOPT_URL,"$GETURL");
$result = curl_exec ($ch);
curl_close ($ch);
$fp = fopen ("$parseURL[host].html", "w");
fwrite($fp,$result);
fclose ($fp);
return $result;
}
$cookieFile = AUTH_SITE_COOKIE_STORE($LOGINURL,$POSTFIELDS);
echo $result = AUTH_SITE_GET($GETURL,$cookieFile);
?>
--
http://www.php.net/manual/en/ref.curl.php
http://master.php.net/manage/user-notes.php?action=edit+20745
http://master.php.net/manage/user-notes.php?action=delete+20745
http://master.php.net/manage/user-notes.php?action=reject+20745