Created
October 27, 2014 12:45
-
-
Save Prithvirajbilla/fa88f3fffe8279ff5adb to your computer and use it in GitHub Desktop.
Get feed From URL with Basic Authorisation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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; | |
} | |
echo getfromweb("http://placements.iitb.ac.in/blog/?feed=rss2","username","password"); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment