public function request($path, $query_array = array(), $options = array())
 {
     $parse_url = parse_url($path);
     $request_url = '';
     if (!isset($parse_url['scheme']) || empty($parse_url['scheme'])) {
         $request_url .= API_DOMAIN;
     }
     $request_url .= $path;
     if ($query_array !== false) {
         $query_array = isset($options['authentication']) && $options['authentication'] == false ? $query_array : LoginRadius::authentication($query_array);
         if (strpos($request_url, "?") === false) {
             $request_url .= "?";
         } else {
             $request_url .= "&";
         }
         $request_url .= LoginRadius::queryBuild($query_array);
     }
     if (in_array('curl', get_loaded_extensions())) {
         $response = $this->curlApiMethod($request_url, $options);
     } elseif (ini_get('allow_url_fopen')) {
         $response = $this->fsockopenApiMethod($request_url, $options);
     } else {
         throw new LoginRadiusException('cURL or FSOCKOPEN is not enabled, enable cURL or FSOCKOPEN to get response from LoginRadius API.');
     }
     if (!empty($response)) {
         $result = json_decode($response);
         if (isset($result->errorCode) && !empty($result->errorCode)) {
             throw new LoginRadiusException($result->message, $result);
         }
     }
     return $response;
 }
 public function request($path, $query_array = array(), $options = array())
 {
     $parse_url = parse_url($path);
     if (isset($parse_url['scheme']) && !empty($parse_url['scheme'])) {
         $validate_url = $path;
     } else {
         $validate_url = API_DOMAIN . $path;
     }
     $method = isset($options['method']) ? strtolower($options['method']) : 'get';
     $post_data = isset($options['post_data']) ? $options['post_data'] : array();
     $content_type = isset($options['content_type']) ? $options['content_type'] : 'form_params';
     $ssl_verify = isset($options['ssl_verify']) ? $options['ssl_verify'] : FALSE;
     $httpclient_options['verify'] = $ssl_verify;
     if ($method == 'post') {
         $httpclient_options[$content_type] = $post_data;
     }
     if ($query_array !== FALSE) {
         $validate_url .= '?' . LoginRadius::queryBuild(LoginRadius::authentication($query_array));
     }
     try {
         $response = \Drupal::httpClient()->{$method}($validate_url, $httpclient_options);
         $data = (string) $response->getBody();
         return $data;
     } catch (RequestException $e) {
         throw new LoginRadiusException($e->getMessage(), $e);
     } catch (ClientException $e) {
         throw new LoginRadiusException($e->getMessage(), $e);
     } catch (Exception $e) {
         throw new LoginRadiusException($e->getMessage(), $e);
     }
 }
 public function request($path, $query_array = array(), $options = array())
 {
     $parse_url = parse_url($path);
     $request_url = '';
     if (!isset($parse_url['scheme']) || empty($parse_url['scheme'])) {
         $request_url .= API_DOMAIN;
     }
     $request_url .= $path;
     $method = isset($options['method']) ? strtolower($options['method']) : 'get';
     $post_data = isset($options['post_data']) ? $options['post_data'] : array();
     $content_type = isset($options['content_type']) ? trim($options['content_type']) : 'x-www-form-urlencoded';
     if ($query_array !== false) {
         $query_array = isset($options['authentication']) && $options['authentication'] == false ? $query_array : LoginRadius::authentication($query_array);
         if (strpos($request_url, "?") === false) {
             $request_url .= "?";
         } else {
             $request_url .= "&";
         }
         $request_url .= LoginRadius::queryBuild($query_array);
     }
     if (in_array('curl', get_loaded_extensions())) {
         $response = $this->curlApiMethod($request_url, $options);
     } elseif (ini_get('allow_url_fopen')) {
         $response = $this->fsockopenApiMethod($request_url, $options);
     } else {
         throw new LoginRadiusException('cURL or FSOCKOPEN is not enabled, enable cURL or FSOCKOPEN to get response from LoginRadius API.');
     }
     $requestedData = array('GET' => $query_array, 'POST' => isset($options['post_data']) ? $options['post_data'] : array());
     $debug_mode = variable_get('lr_social_login_debug_mode');
     if (isset($debug_mode) && $debug_mode == '1') {
         $response_type = 'error';
         if (!empty($response)) {
             $result = json_decode($response);
             if (!isset($result->errorCode)) {
                 $response_type = 'success';
             }
         }
         $logData['endpoint'] = $request_url;
         $logData['method'] = $method;
         $logData['data'] = !empty($requestedData) ? json_encode($requestedData) : '';
         $logData['response'] = json_encode($response);
         $logData['response_type'] = ucfirst($response_type);
         $logData['created_date'] = date("Y-m-d h:i:s A");
         $status = $response_type != 'success' ? WATCHDOG_ERROR : WATCHDOG_INFO;
         watchdog('loginradius_logging', serialize($logData), array(), $status);
     }
     if (!empty($response)) {
         $result = json_decode($response);
         if (isset($result->errorCode) && !empty($result->errorCode)) {
             throw new LoginRadiusException($result->message, $result);
         }
     }
     return $response;
 }
 public function request($path, $query_array = array(), $options = array())
 {
     $parse_url = parse_url($path);
     $request_url = '';
     if (!isset($parse_url['scheme']) || empty($parse_url['scheme'])) {
         $request_url .= API_DOMAIN;
     }
     $request_url .= $path;
     $method = isset($options['method']) ? strtolower($options['method']) : 'get';
     $post_data = isset($options['post_data']) ? $options['post_data'] : array();
     $content_type = isset($options['content_type']) ? trim($options['content_type']) : 'x-www-form-urlencoded';
     if ($query_array !== false) {
         $query_array = isset($options['authentication']) && $options['authentication'] == false ? $query_array : LoginRadius::authentication($query_array);
         if (strpos($request_url, "?") === false) {
             $request_url .= "?";
         } else {
             $request_url .= "&";
         }
         $request_url .= LoginRadius::queryBuild($query_array);
     }
     if (in_array('curl', get_loaded_extensions())) {
         $response = $this->curlApiMethod($request_url, $options);
     } elseif (ini_get('allow_url_fopen')) {
         $response = $this->fsockopenApiMethod($request_url, $options);
     } else {
         throw new LoginRadiusException('cURL or FSOCKOPEN is not enabled, enable cURL or FSOCKOPEN to get response from LoginRadius API.');
     }
     $requestedData = array('GET' => $query_array, 'POST' => isset($options['post_data']) ? $options['post_data'] : array());
     $config = \Drupal::config('sociallogin.settings');
     $debug_mode = $config->get('sociallogin_debug_mode');
     if (isset($debug_mode) && $debug_mode == '1') {
         $response_type = 'error';
         if (!empty($response)) {
             $result = json_decode($response);
             if (!isset($result->errorCode)) {
                 $response_type = 'success';
             }
         }
         $nid = db_insert('loginradius_log')->fields(array('api_url' => $request_url, 'request_type' => $method, 'data' => json_encode($requestedData), 'response' => $response, 'response_type' => ucfirst($response_type), 'timestamp' => REQUEST_TIME))->execute();
     }
     if (!empty($response)) {
         $result = json_decode($response);
         if (isset($result->errorCode) && !empty($result->errorCode)) {
             throw new LoginRadiusException($result->message, $result);
         }
     }
     return $response;
 }
 public function request($path, $query_array = array(), $options = array())
 {
     $parse_url = parse_url($path);
     $request_url = '';
     if (!isset($parse_url['scheme']) || empty($parse_url['scheme'])) {
         $request_url .= API_DOMAIN;
     }
     $request_url .= $path;
     if ($query_array !== false) {
         $query_array = isset($options['authentication']) && $options['authentication'] == false ? $query_array : LoginRadius::authentication($query_array);
         if (strpos($request_url, "?") === false) {
             $request_url .= "?";
         } else {
             $request_url .= "&";
         }
         $request_url .= LoginRadius::queryBuild($query_array);
     }
     if (in_array('curl', get_loaded_extensions())) {
         $response = $this->curlApiMethod($request_url, $options);
     } elseif (ini_get('allow_url_fopen')) {
         $response = $this->fsockopenApiMethod($request_url, $options);
     }
     $response_type = 'error';
     if (isset($response['status']) && $response['status'] == '200') {
         $response_type = 'success';
     }
     $this->_helperActivation = \Magento\Framework\App\ObjectManager::getInstance()->get('LoginRadius\\CustomerRegistration\\Model\\Helper\\Data');
     if ($this->_helperActivation->debug() == '1') {
         $objectManager = \Magento\Framework\App\ObjectManager::getInstance();
         // Instance of object manager
         $resource = $objectManager->get('Magento\\Framework\\App\\ResourceConnection');
         $connection = $resource->getConnection();
         $changelogName = $resource->getTableName('lr_api_log');
         //gives table name with prefix
         $requestedData = array('get' => $query_array, 'post' => isset($options['post_data']) ? $options['post_data'] : '');
         $data = ['api_url' => $request_url, 'requested_type' => isset($options['method']) ? $options['method'] : 'GET', 'data' => json_encode($requestedData), 'response' => json_encode($response['response']), 'response_type' => $response_type, 'created_date' => date('m/d/Y h:i:s a', time())];
         $connection->insert($changelogName, $data);
     }
     if (!empty($response['response'])) {
         $result = json_decode($response['response']);
         if (isset($result->errorCode) && !empty($result->errorCode)) {
             throw new LoginRadiusException($result->message, $result);
         }
     }
     $response = $response['response'];
     return $response;
 }