public function MiniorangeOAuthClientCustomer::getCustomerKeys in OAuth2 Login 8
Get Customer Keys.
File
- src/
MiniorangeOAuthClientCustomer.php, line 142 - Contains miniOrange Customer class.
Class
Namespace
Drupal\oauth2_loginCode
public function getCustomerKeys() {
if (!Utilities::isCurlInstalled()) {
return json_encode(array(
"apiKey" => 'CURL_ERROR',
"token" => '<a href="http://php.net/manual/en/curl.installation.php">PHP cURL extension</a> is not installed or disabled.',
));
}
$url = MiniorangeOAuthClientConstants::BASE_URL . '/moas/rest/customer/key';
$ch = \curl_init($url);
$email = $this->email;
$password = $this->password;
$fields = array(
'email' => $email,
'password' => $password,
);
$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);
\curl_setopt($ch, CURLOPT_MAXREDIRS, 10);
\curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'charset: UTF - 8',
'Authorization: Basic',
));
\curl_setopt($ch, CURLOPT_POST, TRUE);
\curl_setopt($ch, CURLOPT_POSTFIELDS, $field_string);
$content = curl_exec($ch);
if (curl_errno($ch)) {
$error = array(
'%method' => 'getCustomerKeys',
'%file' => 'customer_setup.php',
'%error' => curl_error($ch),
);
\Drupal::logger('oauth2_login')
->notice($error);
}
\curl_close($ch);
return $content;
}