Reason for the creation
It is startling to see that Facebook.com doesn’t yet offer an API, so I made my own. The API is as straightforward (see example) as it gets but I can just imagine some of the cool stuff that could be made using the information found in Facebook. (No longer the case)
Update (Aug 28, 2007)
Based on popular demand the unofficial Facebook API will be restored to its full glory. API 2.0 will be written in Java and will offer more flexibility and power than the old PHP one. If you would like to be notified of its progress or wish to help or wish to tell me anything else feel free to drop a line. Hopefully the development will be quick but who knows since school is about to begin in a week.
Update (Aug 2, 2007)
This API seems to still be sought after despite the public API having been released. Although I no longer offer the API publicly (although some googling will find it) it is still somewhat functional. Since Facebook seems to do everything in form of GET’s I have assembled a pretty good list of all the parameters for all the sites which would facilitate extending my API. However, since my API is not very “safe” I have restrained my use. If anyone is interested in the development or needs advice feel free to contact me. This is truly a fun pastime.
Update (August 16, 2006)
For a project that was conceived only half a year ago, I am surprised how successful it was. Success not because it accomplished all the tasks that a developer might have wanted, but because it brought some change into Facebook. The demand to liberate the information that was previously locked down inside the world of Facebook was the reason for this API to be built and now with Facebook’s own API, I consider this project to be complete.
Features
- Get profiles (and groups)
- Poke friend
- Search other students
- Browse through friends
- Messaging (partially implemented)
Documentation
FacebookAPI::login(email,password)
Returns true if login was succesful, else it returns false.
FacebookAPI::getProfile(id)
Returns array of the information in the student’s profile (based on the student’s id).
FacebookAPI::getFriends(id,filter,pages)
Returns array of friends of the student identified by the id. Filter selects which friends to retrieve. Possible values for filter are: ALL_FRIENDS, SCHOOL_FRIENDS, OTHER_FRIENDS, and UPDATED_FRIENDS. Pages represents the number of pages to be fetched.
FacebookAPI::getGroupMembership(id,pages)
Returns array of groups the user specified is part of (based on id). Pages represents the number of pages to be fetched.
FacebookAPI::advancedSearch(query[], pages)
Returns array with results of the query query. The query is a colletion of one or more of the following elements: name, email, sex(1=Male and 2=Female), city, state, zip, cell, phone, year (ex. 2005), room, and text. Pages defines how many pages of results to fetch from the query: the default is 1 page.
FacebookAPI::pokeFriend(id)
Returns true if poke is successful (based on student’s id).
FacebookAPI::myProfile()
Returns array of the currently logged in user
FacebookAPI::myID()
Returns currently logged in ID number.
FacebookAPI::getMessages(type)
Returns array of messages. Type specifies incoming and outgoing messages (use INCOMING_MSG and OUTGOING_MSG constants to specify which to fetch).
FacebookAPI::readMessage(msg)
Input should be one of the entries returned by getMessage. It returns array with message and all threads the message may have.
FacebookAPI::sendMessage(id, subject, text[,msg])
Sends message to user with specified id. If the message is a reply to an earlier one, msg should be specified. Msg should be one of the entries from getMessages.
Example
// Include API
include("facebookAPI.php");
// Creates new instance of the Facebook API
$foo = new FacebookAPI;
// Logins to Facebook
$foo->login("me@someUniversity.com","password");
// Retrieves user’s profile in array form
$profile= $foo->myProfile();
// Example of how queries are returned:
echo $profile['Name'].' looks like this <img src="'.$profile['image'].'"/>';
To-Do
- Get id codes for fields such as status and schools (for searching)
- Browse groups
- Allow login with multiple accounts
Download:
- Version 0.83 [txt]
Change Log:
- 1/5/06: Initial release.
- 1/9/06: Http header parsing fix to allow page redirection.
- 2/23/06: Poke function added.
- 3/7/06: Updated profile fetching routine.
- 3/9/06: Fixed profile fetching routine. Took care of some bugs.
- 3/12/06: Fixed image fetching RegEx.
- 3/15/06: Fixed getFriends and advancedSearch functions.
- 3/19/06: Basic messaging functions implemented.
- 3/29/06: added getGroupMembership (thanks Adam W.)
Need help?
- Email: andre (dot) cohen (at) gmail.com
- AIM: musicbyte256
Disclaimer:
Use this API at your own risk. There should be no problem in the use of this API if kept for personal use; Otherwise you should probably get permition from Facebook.com