openid_extract_ax_values

function openid_extract_ax_values

openid_extract_ax_values($values, $uris)

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_response

File

modules/openid/openid.inc, line 697
OpenID utility functions.

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;
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/modules!openid!openid.inc/function/openid_extract_ax_values/7.x

在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号

意见反馈
返回顶部