function openid_extract_ax_values

Extracts values from an OpenID AX Response.

The values can be returned in two forms:

  • only openid.ax.value.<alias> (for single-valued answers)
  • both openid.ax.count.<alias> and openid.ax.value.<alias>.<count> (for both single and multiple-valued answers)

Parameters

$values: An array as returned by openid_extract_namespace(..., OPENID_NS_AX).

$uris: An array of identifier URIs.

Return value

An array of values.

See also

http://openid.net/specs/openid-attribute-exchange-1_0.html#fetch_respon…

2 calls to openid_extract_ax_values()
openid_form_user_register_form_alter in modules/openid/openid.module
Implements hook_form_FORM_ID_alter().
_openid_invalid_openid_transition in modules/openid/openid.inc
Provides transition for accounts with possibly invalid OpenID identifiers in authmap.

File

modules/openid/openid.inc, line 698

Code

function openid_extract_ax_values($values, $uris) {
    $output = array();
    foreach ($values as $key => $value) {
        if (in_array($value, $uris) && preg_match('/^type\\.([^.]+)$/', $key, $matches)) {
            $alias = $matches[1];
            if (isset($values['count.' . $alias])) {
                for ($i = 1; $i <= $values['count.' . $alias]; $i++) {
                    $output[] = $values['value.' . $alias . '.' . $i];
                }
            }
            elseif (isset($values['value.' . $alias])) {
                $output[] = $values['value.' . $alias];
            }
            break;
        }
    }
    return $output;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.