Skip to content

Instantly share code, notes, and snippets.

@jordanharper
Created May 26, 2011 12:29
Show Gist options
  • Save jordanharper/993034 to your computer and use it in GitHub Desktop.
Save jordanharper/993034 to your computer and use it in GitHub Desktop.
HTTP authentication with a file_get_contents request
<?php
$context = stream_context_create(array(
'http' => array(
'header' => "Authorization: Basic " . base64_encode("$username:$password")
)
));
$data = file_get_contents($url, false, $context);
@jordanharper
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment