function xrds_parse in Lingotek Translation 7.2
Same name and namespace in other branches
- 7.7 lib/oauth-php/library/discovery/xrds_parse.php \xrds_parse()
- 7.3 lib/oauth-php/library/discovery/xrds_parse.php \xrds_parse()
- 7.4 lib/oauth-php/library/discovery/xrds_parse.php \xrds_parse()
- 7.5 lib/oauth-php/library/discovery/xrds_parse.php \xrds_parse()
- 7.6 lib/oauth-php/library/discovery/xrds_parse.php \xrds_parse()
Parse the xrds file in the argument. The xrds description must have been fetched via curl or something else.
TODO: more robust checking, support for more service documents TODO: support for URIs to definition instead of local xml:id
@exception Exception when the file is in an unknown format
Parameters
string data contents of xrds file:
Return value
array
1 call to xrds_parse()
- OAuthDiscovery::discover in lib/
oauth-php/ library/ OAuthDiscovery.php - * Return a description how we can do a consumer allocation. Prefers static allocation if * possible. If static allocation is possible * * See also: http://oauth.net/discovery/#consumer_identity_types * *
File
- lib/
oauth-php/ library/ discovery/ xrds_parse.php, line 56
Code
function xrds_parse($data) {
$oauth = array();
$doc = @DOMDocument::loadXML($data);
if ($doc === false) {
throw new Exception('Error in XML, can\'t load XRDS document');
}
$xpath = new DOMXPath($doc);
$xpath
->registerNamespace('xrds', 'xri://$xrds');
$xpath
->registerNamespace('xrd', 'xri://$XRD*($v*2.0)');
$xpath
->registerNamespace('simple', 'http://xrds-simple.net/core/1.0');
// Yahoo! uses this namespace, with lowercase xrd in it
$xpath
->registerNamespace('xrd2', 'xri://$xrd*($v*2.0)');
$uris = xrds_oauth_service_uris($xpath);
foreach ($uris as $uri) {
// TODO: support uris referring to service documents outside this one
if ($uri[0] == '#') {
$id = substr($uri, 1);
$oauth = xrds_xrd_oauth($xpath, $id);
if (is_array($oauth) && !empty($oauth)) {
return $oauth;
}
}
}
return false;
}