1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
| $ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 4);
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie);
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
$data = curl_exec($ch);
if (curl_errno($ch)) {
print curl_error($ch);
return false;
}
preg_match("(\d*)", $data, $matches);
$resp_code = $matches[0];
if ( $resp_code != 100 && $resp_code != 301) {
//error( "Response: Authentication Failed: $resp_code");
return false;
}
return $ch; |
Partager