You are here

public static function miniorange_oauth_clientController::get_oauth_timestamp in OAuth2 Login 8

This function is used to get the timestamp value

File

src/Controller/miniorange_oauth_clientController.php, line 49
Contains \Drupal\miniorange_oauth_client\Controller\DefaultController.

Class

miniorange_oauth_clientController

Namespace

Drupal\oauth2_login\Controller

Code

public static function get_oauth_timestamp() {
  $url = 'https://login.xecurify.com/moas/rest/mobile/get-timestamp';
  $ch = \curl_init($url);
  \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);
  \curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);

  // required for https urls
  \curl_setopt($ch, CURLOPT_MAXREDIRS, 10);
  \curl_setopt($ch, CURLOPT_POST, TRUE);
  $content = \curl_exec($ch);
  if (\curl_errno($ch)) {
    echo 'Error in sending curl Request';
    exit;
  }
  \curl_close($ch);
  if (empty($content)) {
    $currentTimeInMillis = round(microtime(TRUE) * 1000);
    $currentTimeInMillis = number_format($currentTimeInMillis, 0, '', '');
  }
  return empty($content) ? $currentTimeInMillis : $content;
}