Answer the question
In order to leave comments, you need to log in
How to make a request from the server to the site and pass authorization?
I make a request to the site with authorization through the following:
But, of course, it doesn’t let me in, how can I log in in this case? file_get_contents("{ссылка}");
Answer the question
In order to leave comments, you need to log in
With what authorization?
Through basic auth like this:
$auth = base64_encode("username:password");
$context = stream_context_create(['http' => ['header' => "Authorization: Basic $auth"]]);
$homepage = file_get_contents("http://example.com/file", false, $context );
And for the usual (via html form) - I recommend using curl. Pass POST parameters and save cookie
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question