curl模拟登入

$url = "http://www.baidu.com";

$ch = curl_init();


curl_setopt($ch, CURLOPT_URL, $url);


//curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);


curl_setopt($ch, CURLOPT_USERPWD, "user:pass");  //最重要的地方 登入的用户名和密码


curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);

 

$output = curl_exec($ch);


$info = curl_getinfo($ch);


curl_close($ch);

print_r($info);

你可能感兴趣的:(curl模拟登入)