You are here

function fontscom_api_headers in @font-your-face 8.3

Provides headers with api parameters.

Parameters

string $path: Fonts.com API endpoint.

Return value

array Header with fonts.com token for API request.

8 calls to fontscom_api_headers()
fontscom_api_add_font_to_current_project in modules/fontscom_api/fontscom_api.module
Adds font to fonts.com project package.
fontscom_api_get_allowed_api_filters in modules/fontscom_api/fontscom_api.module
Retrieves list of allowed api filters.
fontscom_api_get_all_enabled_fonts in modules/fontscom_api/fontscom_api.module
Retrieves list of all enabled fonts from Fonts.com.
fontscom_api_get_all_fonts in modules/fontscom_api/fontscom_api.module
Gets a list of all fonts, in given range.
fontscom_api_get_all_remote_fonts_count in modules/fontscom_api/fontscom_api.module
Gets total font count.

... See full list

File

modules/fontscom_api/fontscom_api.module, line 275
Fonts.com API module file.

Code

function fontscom_api_headers($path) {
  $config = \Drupal::config('fontscom_api.settings');
  $fontscom_token = $config
    ->get('token');
  if (empty($fontscom_token)) {
    return [];
  }
  list($public_key, $private_key) = explode('--', $fontscom_token);
  $encoded = base64_encode(hash_hmac('md5', $public_key . '|' . $path, $private_key, TRUE));
  $auth = urlencode($public_key . ':' . $encoded);
  return [
    'Authorization' => $auth,
    'AppKey' => FONTSCOM_API_APP_KEY,
  ];
}