News Archive
PhpRiot Newsletter
Your Email Address:

More information

WebFinger library for PHP released

Note: This article was originally published at Planet PHP on 24 February 2012.
Planet PHP

I'm implementing OpenID for SemanticScuttle, your self-hosted social bookmark manager. To log in with OpenID, you need to know your OpenID URL, which many people do not know, and don't want to know. Most know their email address, and thanks to WebFinger, this is all you have to know!

WebFinger enables applications to discover information about people by just their e-mail address - for example their OpenID URL!

I didn't find a single standalone WebFinger library for PHP, so I asked on StackOverflow, but did not get any responses. Failed to stand on the shoulders of giants, I went the hard way and implemented it all myself: Net_WebFinger, based on XML_XRD.


WebFinger weaves RFC 6415: Web Host Metadata with LRDD which both use XRD files.

Thus the first step was to build a clean XRD library for PHP, with an intuitive API and 100% unit test coverage. I proposed the XML_XRD package on 2012-02-01, called for votes 8 days later. It was accepted with 11 votes. Extensive documentation does also exist now.

After the foundation was laid, I proposed the Net_WebFinger package. It was accepted as new PEAR this night, and just some minutes ago it got its first official release and a lot of documenation.


So, discovery is easy now! First, install the PEAR package:

$ pear install net_webfinger-alpha

Now the PHP code:

finger(''); if ($react-openid !== null) { echo 'OpenID provider found: ' . $react-openid . "\n"; } //list all other links: foreach ($react as $link) { echo 'Link: ' . $link-rel . ' to ' . $link-href . "\n"; } ?

WebFinger CLI

Net_WebFinger ships with a command line client that you can use to try it out. Find it with

$ pear list-files net_webfinger|grep cli doc /usr/share/php/docs/Net_WebFinger/examples/webfinger-cli.php

Yahoo and Google already support WebFinger. Distributed social networks like (that powers and Diaspora use WebFinger to distribute public encryption keys, OStatus and Salmon URLs. You can try one of those user addresses, too.

$ php /usr/share/php/docs/Net_WebFinger/examples/webfinger-cli.php Discovering Information secure? false OpenID provider: Link: Link: Link: Link: Link: Link: Link: describedby: Link: describedby: Link: $ php /usr/share/php/docs/Net_WebFinger/examples/webfinger-cli.php Discovering singpolyma@

Truncated by Planet PHP, read more at the original (another 1043 bytes)