Skip to content

Instantly share code, notes, and snippets.

@aaoliveira
Forked from anonymous/auth.php
Created September 13, 2016 23:40
Show Gist options
  • Save aaoliveira/d9d7c0cc43e7c51567345fd2e0436bc7 to your computer and use it in GitHub Desktop.
Save aaoliveira/d9d7c0cc43e7c51567345fd2e0436bc7 to your computer and use it in GitHub Desktop.
Exemplo autenticação http basic
$login = 'hjk3kj3h534h53kj4j345';
$password = '3k45jh3k4j5h3k4j5h34kh5k34';
$url = 'https://apic1.hml.stelo.com.br/';
$encode = base64_encode("$login:$password");
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_TIMEOUT, 30); //timeout after 30 seconds
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_HTTPHEADER,
array(
"Authorization: Basic " . $encode)
));
$status_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); //get status code
$result=curl_exec ($ch);
curl_close ($ch);
echo $result;
echo $status_code;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment