Welcome to MoochSpot!

MoochSpot is where you can come to keep track of how much money you and your friends owe each other. Whenever you loan someone some money or borrow a bit, just come here and enter the loan. We'll keep track of it for you. But we'll do more than just remember that you owe Joe $5 and Mary $10 -- we'll keep track of the group as a whole using Piggy Banks.

Piggy Banks are the heart of MoochSpot. A Piggy Bank is how you share debts among a group of friends. Say you loan $20 to Marcel, and Marcel loans $30 to Ruchi. If both loans are in the same Piggy Bank, then we'll tell Ruchi to pay $20 to you and $10 to Marcel, settling all your debts.

That's a simple example, of course. The more friends you have in a Piggy Bank, the more time it'll save you -- imagine borrowing money from 20 friends and paying everything back to just one person! We will keep track of it all so you won't have to worry about tracking down people who owe you money.

Technical details

MoochSpot is a live demonstration of the kind of site you can build using the Facebook API.

It is built in Java using the excellent RIFE framework. It uses only the published Facebook API calls.

Our database stores the Facebook user ID and real name of each user who has either signed up for MoochSpot or who has been added to a piggy bank by a friend. The Facebook user ID is mapped to a separate internal user ID for use in the tables that track balances and piggy bank membership.

Most of the site is built exactly the same way one would build a site without Facebook integration. We call the Facebook API on all pages where we list the user's friends (e.g. the "pay a friend" page) and at login time. At login we simply treat the Facebook UID as the user's login name, and let our Web framework handle all the session management as we would do on a non-Facebook Web site.

Code Excerpts

This code uses the Java Facebook API client.

Generic API code

FacebookApi.java
A higher-level wrapper around the Facebook API operations we use.
FacebookFriend.java
Object representation of a friend. Used by FacebookApi.
FacebookFriends.java
Container for a set of FacebookFriend objects. Used by FacebookApi.

RIFE authentication

See the RIFE user's guide or the RIFE Wiki's authentication system internals pages for more background about RIFE's authentiation system. These classes demonstrate how the Facebook API can integrate into an existing authentication framework.
FacebookAuthenticated.java
Authentication layer. This adds new users to the database and validates session keys. It uses FacebookApi and related classes above.
FacebookCredentials.java
Wrapper for Facebook user ID and session data. Used by FacebookAuthenticated.