function fonts_com_get_key_for_account in @font-your-face 7.2
Gets auth key for a given account.
1 call to fonts_com_get_key_for_account()
- fonts_com_setup_form_submit in modules/
fonts_com/ fonts_com.module - Handles account settings form submit.
File
- modules/
fonts_com/ api.inc, line 123 - API functions.
Code
function fonts_com_get_key_for_account($email, $password) {
$key = fonts_com_get_existing_key_for_account($email, $password);
if ($key) {
return $key;
}
$path = '/rest/json/Accounts/?wfsemail=' . $email;
$response = drupal_http_request(FONTS_COM_API_BASE_URL . $path, array(
'headers' => array(
'AppKey' => FONTS_COM_API_APP_KEY,
'Password' => $password,
),
));
if ($response->code == 200) {
$data = json_decode($response->data);
if (isset($data->Accounts) && isset($data->Accounts->Account) && isset($data->Accounts->Account->AuthorizationKey)) {
$key = $data->Accounts->Account->AuthorizationKey;
}
else {
drupal_set_message(t('The submitted email and password were not recognized by Fonts.com.'), 'error');
fontyourface_log('Invalid drupal_http_request response: @response', array(
'@response' => print_r($response, TRUE),
));
}
// else
}
else {
drupal_set_message(t('There was an error getting your key from Fonts.com.'), 'error');
fontyourface_log('Invalid drupal_http_request response: @response', array(
'@response' => print_r($response, TRUE),
));
}
// else
return $key;
}