Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Get feed From URL with Basic Authorisation
function getfromweb($url, $username = null, $password = null) {
$opts = array('http' =>
'method' => 'GET',
'header' => "Authorization: Basic ".base64_encode("$username:$password")."\r\n")
$context = stream_context_create($opts);
$result = file_get_contents($url, false, $context);
return $result;
echo getfromweb("","username","password");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment