Jump to content

[PHP] HTTP server


Spajk

Recommended Posts

This probably isnt the right section, but this is the only place where I think I can get the answer.

I created a page on MTA's inbuild HTTP server that changes dynamicly. Now I want to create a PHP script that would get the content of that page.

That wouldnt be a problem, but when viewing the page, MTA's http server requiers to login with account's user/pass combination.

Is there a way to bypass this authorisation or to make the PHP script actually login with certain user/pass and view(read) the page.

Thanks in advance, Spajk.

Link to comment

That helped a lot. I searched thru PHP SDK source code and I found that MTA HTTP server uses basic authorization method. With some google-ing, I managed to find a function to get page content. Thanks.

 function http_auth_get($url,$username,$password){    $cred = sprintf('Authorization: Basic %s',base64_encode("$username:$password") );    $opts = array('http'=>array('method'=>'GET','header'=>$cred));    $ctx = stream_context_create($opts);    $handle = fopen ( $url, 'r', false,$ctx);        return stream_get_contents($handle);} 

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...