|

02-05-2009, 06:32 PM
|
| Junior Member | | Join Date: Feb 2009
Posts: 1
| |
Video is too quite, code sucked, try this: Quote:
function fetch($url,$post=false,$cookie=false,$timeout=30) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
if ($cookie) {
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie);
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie);
}
if ($post) {
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
curl_setopt($ch, CURLOPT_POST, TRUE);
}
curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
//curl_setopt($ch, CURLOPT_HEADER, TRUE); //debug
$output=curl_exec($ch);
curl_close($ch);
return $output;
}
$cookie=tempnam('','');
$url='http://www.example.com/login.php';
$post='username=example&password=qwerty';
fetch($url,$post,$cookie);
$url='http://www.example.com/something/important.zip';
echo fetch($url,false,$cookie);
?> | I'm sure you get the idea.
|