Created
September 13, 2016 23:31
-
-
Save anonymous/08e2566f4dcf51df39bf4463008e6bf8 to your computer and use it in GitHub Desktop.
Exemplo autenticação http basic
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$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