You are previewing Beautiful Architecture.

Beautiful Architecture

Cover of Beautiful Architecture by Georgios Gousios... Published by O'Reilly Media, Inc.
O'Reilly logo

Creating a Social Web Service

Looking back on an example as simple as http://fettermansbooks.com, it becomes clear that most Internet applications would benefit from added social context for the data they present. However, we run into a product problem: the availability of that data.

product problem: Applications could make use of a user’s social data on Facebook, but this data is inaccessible.

data solution: Make Facebook data available through an externally accessible web service (Figure 6-2).

The addition of the Facebook API to Facebook’s architecture begins the relationship between external applications and Facebook through the Facebook Platform, essentially adding Facebook’s data to the external application’s stack. For a Facebook user, this integration begins when he explicitly authorizes the outside application to obtain social data on his behalf.

The application stack consumes Facebook data as web service

Figure 6-2. The application stack consumes Facebook data as web service

Example 6-4 shows what the code behind the landing page of http://fettermansbooks.com might look like without any Facebook integration.

Example 6-4. Example book site logic

$books_user_id = establish_booksite_userid($_REQUEST);
$book_infos = user_get_likely_books($books_user_id);
display_books($book_infos);

This user_get_likely_books function operates entirely from the data that the book application controls, possibly using clever relevance techniques to guess at a user’s ...

The best content for your career. Discover unlimited learning on demand for around $1/day.