You can use the Facebook graph API :
http://developers.facebook.com/docs/reference/api/
look for the searching section,
QUOTE from fb:
Searching
You can search over all public objects in the social graph with https://graph.facebook.com/search. The format is:
https://graph.facebook.com/search?q=QUERY&type=OBJECT_TYPE
We support search for the following types of objects:
All public posts: https://graph.facebook.com/search?q=watermelon&type=post
- People:
https://graph.facebook.com/search?q=mark&type=user - Pages:
https://graph.facebook.com/search?q=platform&type=page - Events:
https://graph.facebook.com/search?q=conference&type=event - Groups:
https://graph.facebook.com/search?q=programming&type=group - Places:
https://graph.facebook.com/search?q=coffee&type=place¢er=37.76,122.427&distance=1000 - Checkins:
https://graph.facebook.com/search?type=checkin
You can also search an individual
user’s News Feed, restricted to that
user’s friends, by adding a q
argument to the home connection URL:
- News Feed:
https://graph.facebook.com/me/home?q=facebook