O'Reilly logo

Programming Social Applications by Jonathan LeBlanc

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Implementing WebFinger

Working with the WebFinger protocol is actually very easy. You simply make a series of cURL requests to a provider that implements WebFinger, which subsequently returns all of the information we need, as shown in Figure 10-4.

How WebFinger works

Figure 10-4. How WebFinger works

When a web application or service makes a request to a web source that uses WebFinger in order to obtain user information from that site, the web source will return either user record details or error information in the event that no user data was located.

As an example, let’s take a look at extracting profile information using Google’s WebFinger implementation. First, we will make a request to the /.well-known/host-meta file on Google to obtain more data about how Google’s WebFinger implementation works to extract profile information based on users’ email addresses. From a command prompt, we enter the following:

curl http://gmail.com/.well-known/host-meta

Note

When implementing this procedure in a product or service, you can use the PHP cURL library (http://php.net/manual/en/book.curl.php) or PycURL for Python (http://pycurl.sourceforge.net/).

The response that is returned will contain data about the URI template format that Google uses to obtain the user’s profile from her email address:

<?xml version='1.0' encoding='UTF-8'?> <!-- NOTE: this host-meta end-point is a pre-alpha work in progress. Don't rely on it. ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required