curl - php: get content of a protected page? -
i trying html code of protected page. aiming restyle page css, need tho html code first !!!
i have valid username , password.
i have tried use curl, end message: "the stub received bad data"
the url of page is: http://student.guc.edu.eg
do have code already? need use code such this, utilising curlopt_httpauth
, curlopt_userpwd
specifically.
$username = 'studentid'; $password = 'studentpassword'; $ch = curl_init("http://student.guc.edu.eg/"); curl_setopt($ch, curlopt_returntransfer, 1); curl_setopt($ch, curlopt_header, 0); curl_setopt($ch, curlopt_httpauth, curlauth_basic); curl_setopt($ch, curlopt_userpwd, $username . ":" . $password); $html = curl_exec($ch); curl_close($ch);
curlopt_httpauth
the http authentication method(s) use. options are: curlauth_basic, curlauth_digest, curlauth_gssnegotiate, curlauth_ntlm, curlauth_any, , curlauth_anysafe.
the bitwise | (or) operator can used combine more 1 method. if done, curl poll server see methods supports , pick best one.
curlauth_any alias curlauth_basic | curlauth_digest | curlauth_gssnegotiate | curlauth_ntlm.
curlauth_anysafe alias curlauth_digest | curlauth_gssnegotiate | curlauth_ntlm.
curlopt_userpwd
a username , password formatted "[username]:[password]" use connection.
looking @ headers returned site http://student.guc.edu.eg/, it's follows:
> curl -i http://student.guc.edu.eg/ http/1.1 401 access denied server: microsoft-iis/5.0 date: thu, 21 jul 2011 08:18:34 gmt www-authenticate: ntlm www-authenticate: basic realm="student.guc.edu.eg" connection: close content-length: 4431 content-type: text/html
this means rather using curlauth_basic
, should try curlauth_ntlm
, , see if helps.
Comments
Post a Comment