Skip to content

Instantly share code, notes, and snippets.

@MindOverJohn
MindOverJohn / getfeed.php
Created May 13, 2020 16:04 — forked from Prithvirajbilla/getfeed.php
Get feed From URL with Basic Authorisation
<?php
function getfromweb($url, $username = null, $password = null) {
$opts = array('http' =>
array(
'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;