Downloading HTTP Basic-Authenticated Pages with PHP and CURL
Articles > PHP
It's really quite simple. Make sure you have the CURL extension loaded and running.
If you're downloading via HTTPS, you may need to enable CURLOPT_SSL_VERIFYPEER. You can also combine this with Uploading via POST with PHP and CURL.
It's really quite simple. Make sure you have the CURL extension loaded and running.
// use curl to get basic authentication $url = "https://api.del.icio.us/v1/posts/all?"; $username = "delicious.username"; $password = "delicious.password"; $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_USERPWD, $username . ":" . $password); $content = curl_exec($curl);
If you're downloading via HTTPS, you may need to enable CURLOPT_SSL_VERIFYPEER. You can also combine this with Uploading via POST with PHP and CURL.