1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
|
<?php
$client_id = base64_encode('MONIDCLIENT');
$client_secret = base64_encode('MONPASSWORD');
$auth_string = "{$client_id}:{$client_secret}";
$request = "https://auth.masternautconnect.com/masternauth-oauth/oauth/accessToken"; // Essayer en ajoutant ?grant_type=client_credentials sans succès
$ch = curl_init($request);
curl_setopt_array($ch, array(
CURLOPT_POST => TRUE,
CURLOPT_RETURNTRANSFER => TRUE,
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_USERPWD => $auth_string,
CURLOPT_HTTPHEADER => array('Content-Type: application/json;charset=UTF-8;',)
)
);
$response = curl_exec($ch);
curl_close ($ch) ;
//Vérification des erreurs
if ($response === FALSE) {
die(curl_error ($ch));
echo "Une erreur s'est produite " ;
}
else{ echo $response; }
?> |
Partager