PHP read from a webpage that requires authentication
<p>I'm trying to get the content of a webpage that require authentication using PHP.<br>
Ideally, I'd like to use the simple html dom parser: <a href="http://simplehtmldom.sourceforge.net" rel="nofollow">http://simplehtmldom.sourceforge.net</a>.<br>
Anyone knows of a way to do this?</p>

<p>Edit:<br>
Tried the following code:<br>
<code>$ch = curl_init();<br>
curl_setopt($ch, CURLOPT_URL, $url);<br>
curl_setopt($ch, CURLOPT_POSTFIELDS, 'username=' . urlencode($username) . '&amp;password=' . urlencode($pass));<br>
curl_setopt($ch, CURLOPT_POST, 1);<br>
curl_setopt($ch, CURLOPT_HEADER, 0);<br>
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);<br>
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);<br>
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);<br>
curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);<br>
echo curl_exec($ch);<br>
curl_close($ch);
</code></p>

<p>But now I get a 405 HTTP error.</p>
