PHP to retrieve the content of the Password Required pages once i have password?
Use curlcurl_setopt ( resource $ch , int $option , mixed $value )
option = CURLOPT_HTTPAUTHvalue = choose auth type (CURLAUTH_BASIC, ...)
Look at using a Cookie Jar.
When you first authenticate, the "Cookie" that stores your authentication is lost (assuming your not already using a Cookie Jar), so the next request you make, won't know you have logged in.
As a result, you need to use a Cookie Jar to store the authentication cookie.
It depends on the type of authentication required. If it's the widely used Basic Auth type, it's a trivial header added to the request. You can see the technical details well explained at Wikipedia. To add a header to the request using file_get_contents
, use the $context
parameter, the use of which is explained with an example here.