|
The code is pretty self-explanatory. The only know-how is the combination of the options which works with LJ. UPD: (The Russian version): function get($url) {
global $digest_username, $digest_password;
if (!$digest_username)
return file_get_contents($url);
$auth = "$digest_username:$digest_password";
$ch = curl_init();
curl_setopt($ch, CURLOPT_FORBID_REUSE, 1);
curl_setopt($ch, CURLOPT_FRESH_CONNECT, 1);
curl_setopt($ch, CURLOPT_AUTOREFERER, true);
curl_setopt($ch, CURLOPT_UNRESTRICTED_AUTH, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_DIGEST);
curl_setopt($ch, CURLOPT_USERPWD, $auth);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$res = curl_exec($ch);
curl_close($ch);
return $res;
} UPD: Some discussion can be found here: http://tl1.livejournal.com/351315.html
Tags: Сетевая жизнь, Программирование.
Archives
|
