Spajk Posted April 17, 2013 Share Posted April 17, 2013 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
LoveFist Posted April 17, 2013 Share Posted April 17, 2013 Try PHP SDK - https://wiki.multitheftauto.com/wiki/PHP_SDK Link to comment
Spajk Posted April 19, 2013 Author Share Posted April 19, 2013 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
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now