function MiniorangeOAuthCustomer::updateStatus in Drupal OAuth & OpenID Connect Login - OAuth2 Client SSO Login 7
File
- includes/
customer_setup.php, line 376 - Contains miniOrange Customer class.
Class
- MiniorangeOAuthCustomer
- @file This class represents configuration for customer.
Code
function updateStatus() {
$url = MiniorangeOAuthConstants::BASE_URL . '/moas/api/backupcode/updatestatus';
$ch = curl_init($url);
$customerKey = variable_get('miniorange_oauth_client_customer_id');
$apiKey = variable_get('miniorange_oauth_client_customer_api_key');
$currentTimeInMillis = round(microtime(TRUE) * 1000);
$stringToHash = $customerKey . number_format($currentTimeInMillis, 0, '', '') . $apiKey;
$hashValue = hash("sha512", $stringToHash);
$customerKeyHeader = "Customer-Key: " . $customerKey;
$timestampHeader = "Timestamp: " . number_format($currentTimeInMillis, 0, '', '');
$authorizationHeader = "Authorization: " . $hashValue;
$key = variable_get('miniorange_oauth_client_customer_admin_token');
$code = AESEncryption::decrypt_data(variable_get('miniorange_oauth_client_license_key'), $key);
$fields = array(
'code' => $code,
'customerKey' => $customerKey,
);
$field_string = json_encode($fields);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_ENCODING, "");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_AUTOREFERER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
// required for https urls
curl_setopt($ch, CURLOPT_MAXREDIRS, 10);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
$customerKeyHeader,
$timestampHeader,
$authorizationHeader,
));
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $field_string);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
curl_setopt($ch, CURLOPT_TIMEOUT, 20);
$content = curl_exec($ch);
if (curl_errno($ch)) {
echo 'Request Error:' . curl_error($ch);
exit;
}
curl_close($ch);
return $content;
}