PHP

PHP CURL WITH BASIC HTTP AUTH

THE SETTINGS $url = "http://site.com/protected/"; $user = "USER"; $password = "PASS";

CURL BASIC AUTH

01

CURL INIT $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, URLOPT_HTTPAUTH,  CURLAUTH_BASIC); curl_setopt($ch, CURLOPT_USERPWD,  "$user:$password"); curl_setopt($ch,  CURLOPT_RETURNTRANSFER, 1);

CURL RUN  $result = curl_exec($ch); 

AuthType Basic AuthName "Password Required" AuthUserFile PATH/FOLDER/.htpasswd Require valid-user

HTACCESS BASIC AUTH

02