I have a php code which retrieves a atom feed in a DOMDocument (the feed is not saved to file)
I need to start using basic authentication for retrieving the feed.
Is it possible, or do I have to save the feed to file first?
My working code:
$doc = new DOMDocument();
$doc->load($feedurl);
$feed = $doc->getElementsByTagName("entry");
I have tried this:
$context = stream_context_create(array(
'http' => array(
'header' => "Authorization: Basic " . base64_encode("$username:$password")
)
));
$doc = new DOMDocument();
$doc->load($feedurl, context);
$feed = $doc->getElementsByTagName("entry");
But it does not work (I get a empty $doc
)
Anyone know how to do this?