Answer the question
In order to leave comments, you need to log in
How to give access to the price list of Yandex.Market by login and password?
The site generates an XML price list for the market when you click on a specific link. In the import settings on Yandex, it is possible to set a login and password for accessing the server, but it is not described how Yandex makes a request. Tell me how to check the login and password that Yandex.market sends using PHP to display the price list only if the login and password match?
Answer the question
In order to leave comments, you need to log in
I found the solution myself:
// Если пользователь не авторизовался
if(!isset($_SERVER['PHP_AUTH_USER'])) {
header('WWW-Authenticate: Basic realm="My Realm"');
header('HTTP/1.0 401 Unauthorized');
echo lang('To view a page that requires authorization', $this->moduleName);
exit;
} else {
// Проверяет введенный логин и пароль
if ($_SERVER['PHP_AUTH_USER'] == $this->api->loadConfig('login') && $_SERVER['PHP_AUTH_PW'] == $this->api->loadConfig('password')){
// Выводит XML-файл
} else {
// Выводит 404
}
}
It is better to check using a web server (Nginx).
nginx.org/ru/docs/http/ngx_http_auth_basic_module.html
nginx.org/ru/docs/http/ngx_http_secure_link_module.html
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question