Skip to content

Instantly share code, notes, and snippets.

@jsifalda
Created December 10, 2012 18:40
Show Gist options
  • Select an option

  • Save jsifalda/4252401 to your computer and use it in GitHub Desktop.

Select an option

Save jsifalda/4252401 to your computer and use it in GitHub Desktop.
Sending basic authentication via curl
<?php
$url = 'http://www.example.com';
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_USERPWD, "myusername:mypassword");
$result = curl_exec($ch);
echo $result;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment