You are here

function fonts_com_create_account in @font-your-face 7.2

Creates a new account.

1 call to fonts_com_create_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 197
API functions.

Code

function fonts_com_create_account($email, $first_name, $last_name) {
  $success = FALSE;
  $path = '/rest/json/Accounts/';
  $response = drupal_http_request(FONTS_COM_API_BASE_URL . $path, array(
    'headers' => array(
      'AppKey' => FONTS_COM_API_APP_KEY,
    ),
    'method' => 'POST',
    'data' => 'wfsfirst_name=' . $first_name . '&wfslast_name=' . $last_name . '&wfsemail=' . $email,
  ));
  if ($response->code == 200) {
    $data = json_decode($response->data);
    if (isset($data->Accounts) && isset($data->Accounts->Message) && $data->Accounts->Message == 'Success') {
      $success = TRUE;
    }
    else {
      drupal_set_message(t('Fonts.com as unable to create your account.'), '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 creating an account at Fonts.com.'), 'error');
    fontyourface_log('Invalid drupal_http_request response: @response', array(
      '@response' => print_r($response, TRUE),
    ));
  }

  // else
  return $success;
}