You are here

function hook_api_tokens_info in API Tokens 7

Declare API tokens.

Token example: Non-parametric: [api:demo/] Parametric: [api:demo["param1", {"param2": {"key1": "value1"}}]/] Parameters part must be a valid JSON array. Extra spaces are allowed.

Return value

array Array of tokens to register.

1 function implements hook_api_tokens_info()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

api_tokens_example_api_tokens_info in api_tokens_example/api_tokens_example.module
Implements hook_api_tokens_info().
1 invocation of hook_api_tokens_info()
api_tokens_collect_tokens in ./api_tokens.module
Collects information on all the tokens in the system.

File

./api_tokens.api.php, line 24
Hooks provided by the API Tokens module.

Code

function hook_api_tokens_info() {

  // Token key must be lowercase, may contain
  // following characters: "a-z", "-", "_", ":"
  $tokens['demo'] = array(
    // Title of the token
    // If omitted, token key will be used
    // Optional.
    'title' => t('Demo'),
    // Description of the token
    // Optional.
    'description' => t('Description of the Demo API token'),
    // Name of the token process function
    // Must be defined within the module or its include file
    // If omitted, will be set to [%module_name]_apitoken_[%token_name]
    // ("-" and ":" characters are replaced with "_")
    // Optional
    'handler' => 'modulename_apitoken_demo',
    // Relative path to the token process function without extension.
    // If omitted, means that the process function located in .module file
    // Optional
    // modulename/includes/handlers.inc
    'inc' => 'includes/handlers',
    // Number of required parameters of the process function
    // If omitted, api_tokens_param_info() will be used to
    // determine the number of required parameters
    // Optional.
    'params' => 2,
    // Determines caching method for the output of the token process function
    // Allowed values:
    // - DRUPAL_NO_CACHE [default]
    // - DRUPAL_CACHE_PER_ROLE
    // - DRUPAL_CACHE_PER_USER
    // - DRUPAL_CACHE_PER_PAGE
    // - DRUPAL_CACHE_GLOBAL
    // If omitted, DRUPAL_NO_CACHE will be used
    // Optional.
    'cache' => DRUPAL_CACHE_PER_PAGE | DRUPAL_CACHE_PER_ROLE,
    // Makes sence when cache is set to other then DRUPAL_NO_CACHE
    // Allowed values:
    // - CACHE_PERMANENT (0)
    // - CACHE_TEMPORARY (-1) [default]
    // - Cache lifetime number in seconds
    // If omitted, CACHE_TEMPORARY will be used
    // Optional
    // 5 minutes.
    'cache_expire' => 300,
  );
  return $tokens;
}