edit this page - page history - about editing

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.

// 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 CURLOPTSSLVERIFYPEER. You can also combine this with Uploading via POST with PHP and CURL.
Categories: PHP | Article | Published Code
edit this page - what links to here? - page history - top
Last edited by jevon jevon 135 months ago