Skip to content

Instantly share code, notes, and snippets.

@aaoliveira
Created September 14, 2016 00:07
Show Gist options
  • Save aaoliveira/3e08076f2674013faf455cba41b9d603 to your computer and use it in GitHub Desktop.
Save aaoliveira/3e08076f2674013faf455cba41b9d603 to your computer and use it in GitHub Desktop.
Segundo exemplo de auth
try {
$clientId ='cf8db6fe61bc1efebc6ae4f5ab4af60c';
$clientSecret = 'f538b73a11eac49827f6da678e859fa7';
$auth_token = base64_encode($clientId . ':' . $clientSecret);
$target_url = 'https://apic1.hml.stelo.com.br';
$ch = curl_init($target_url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_USERPWD, $clientId . ':' . $clientSecret);
$headers = array('Authorization=Basic ' . $auth_token);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1);
curl_setopt($ch, CURLOPT_FRESH_CONNECT, true);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_MAXREDIRS, 5);
$response_data = curl_exec($ch);
$info = curl_getinfo($ch);
var_dump($response_data);
curl_close($ch);
} catch (Exception $e) {
echo $e->getMessage();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment