You are here

function xrds_xrd_oauth_service in Lingotek Translation 7.6

Same name and namespace in other branches
  1. 7.7 lib/oauth-php/library/discovery/xrds_parse.php \xrds_xrd_oauth_service()
  2. 7.2 lib/oauth-php/library/discovery/xrds_parse.php \xrds_xrd_oauth_service()
  3. 7.3 lib/oauth-php/library/discovery/xrds_parse.php \xrds_xrd_oauth_service()
  4. 7.4 lib/oauth-php/library/discovery/xrds_parse.php \xrds_xrd_oauth_service()
  5. 7.5 lib/oauth-php/library/discovery/xrds_parse.php \xrds_xrd_oauth_service()

Parse a service definition for OAuth in a simple xrd element

Parameters

DOMElement n:

Return value

array (type, service desc)

1 call to xrds_xrd_oauth_service()
xrds_xrd_oauth in lib/oauth-php/library/discovery/xrds_parse.php
Parse a XRD definition for OAuth and return the uris etc.

File

lib/oauth-php/library/discovery/xrds_parse.php, line 158

Code

function xrds_xrd_oauth_service($n) {
  $service = array(
    'uri' => '',
    'signature_method' => array(),
    'parameters' => array(),
  );
  $type = false;
  foreach ($n->childNodes as $c) {
    $name = $c->nodeName;
    $value = $c->nodeValue;
    if ($name == 'URI') {
      $service['uri'] = $value;
    }
    else {
      if ($name == 'Type') {
        if (strncmp($value, 'http://oauth.net/core/1.0/endpoint/', 35) == 0) {
          $type = basename($value);
        }
        else {
          if (strncmp($value, 'http://oauth.net/core/1.0/signature/', 36) == 0) {
            $service['signature_method'][] = basename($value);
          }
          else {
            if (strncmp($value, 'http://oauth.net/core/1.0/parameters/', 37) == 0) {
              $service['parameters'][] = basename($value);
            }
            else {
              if (strncmp($value, 'http://oauth.net/discovery/1.0/consumer-identity/', 49) == 0) {
                $type = 'consumer_identity';
                $service['method'] = basename($value);
                unset($service['signature_method']);
                unset($service['parameters']);
              }
              else {
                $service['unknown'][] = $value;
              }
            }
          }
        }
      }
      else {
        if ($name == 'LocalID') {
          $service['consumer_key'] = $value;
        }
        else {
          if ($name[0] != '#') {
            $service[strtolower($name)] = $value;
          }
        }
      }
    }
  }
  return array(
    $type,
    $service,
  );
}