Hello i have command line code:
curl 'http://192.168.0.1:80/' -H 'Authorization: Basic my_auth'
In php:
$process = curl_init($ip);
//just for "shore"
curl_setopt($data, CURLOPT_HTTPHEADER,
array(
"Authorization: Basic " . base64_encode($username . ":" . $password)
));
curl_setopt($process, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
curl_setopt($process, CURLOPT_USERPWD, $login . ":" . $password);
curl_setopt($process, CURLOPT_CONNECTTIMEOUT, 10);
curl_setopt($process, CURLOPT_TIMEOUT, 10);
curl_setopt($process, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($process, CURLOPT_VERBOSE, 1);
curl_setopt($process, CURLOPT_HEADER, 1);
$return = curl_exec($process);
in result i see: 401... In apache2 log:
- HTTP 1.0, assume close after body < HTTP/1.0 401 Unauthorized < Date: Fri, 15 Jul 2016 09:27:20 GMT < Server: Boa/0.94.13 < Connection: close < WWW-Authenticate: Basic realm="service" < Content-Type: text/html; charset=ISO-8859-1 < Set-Cookie: SESSIONID=068054d0; <
- Closing connection 53
- Issue another request to this URL: ''
- Hostname was found in DNS cache
- Trying 192.168.0.1...
- Connected to 192.168.0.1 (192.168.0.1) port 80 (#54)
Server auth using Basic with user 'admin'
GET / HTTP/1.0 Authorization: Basic my_code Host: 192.168.0.1 Accept: /
HTTP 1.0, assume close after body < HTTP/1.0 401 Unauthorized < Date: Fri, 15 Jul 2016 09:27:20 GMT < Server: Boa/0.94.13 < Connection: close
- Authentication problem. Ignoring this. < WWW-Authenticate: Basic realm="service" < Content-Type: text/html; charset=ISO-8859-1 < Set-Cookie: SESSIONID=068054d0; <
- Closing connection 54