XML_XRD
[ class tree: XML_XRD ] [ index: XML_XRD ] [ all elements ]

Source for file webfinger.php

Documentation is available at webfinger.php

  1. <?php
  2. /**
  3.  * Basic WebFinger implementation to discover a user's OpenID provider
  4.  * from just his email address
  5.  */
  6. if ($argc < 2{
  7.     echo "Usage: $argv[0] user@example.com\n";
  8.     exit(1);
  9. }
  10. $email $argv[1];
  11.  
  12. $host substr($emailstrpos($email'@'+ 1);
  13.  
  14. require_once 'XML/XRD.php';
  15. $xrd = new XML_XRD();
  16. try {
  17.     $xrd->loadFile(
  18.         'https://' $host '/.well-known/webfinger?resource=acct:' $email,
  19.         'json'
  20.     );
  21. catch (XML_XRD_Exception $e{
  22.     echo 'Loading JRD file failed: '  $e->getMessage("\n";
  23.     exit(1);
  24. }
  25.  
  26. $openIdLink $xrd->get('http://specs.openid.net/auth/2.0/provider');
  27. if ($openIdLink === null{
  28.     echo "No OpenID provider found for $email\n";
  29.     exit(2);
  30. }
  31.  
  32. echo $email '\'s OpenID provider is: ' $openIdLink->href . "\n";
  33. ?>

Documentation generated on Mon, 11 Mar 2019 15:57:48 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.