Skip to content

Instantly share code, notes, and snippets.

@Prithvirajbilla
Created October 27, 2014 12:45
Show Gist options
  • Save Prithvirajbilla/fa88f3fffe8279ff5adb to your computer and use it in GitHub Desktop.
Save Prithvirajbilla/fa88f3fffe8279ff5adb to your computer and use it in GitHub Desktop.

Revisions

  1. Prithvirajbilla created this gist Oct 27, 2014.
    15 changes: 15 additions & 0 deletions getfeed.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,15 @@
    <?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");
    ?>