|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sf.f8api.FacebookApi
public class FacebookApi
Stateless communication interface.
Nested Class Summary | |
---|---|
protected static class |
FacebookApi.Pair<N,V>
Manage name-value pairs. |
Field Summary | |
---|---|
static java.lang.String |
API_VERSION
|
protected static int |
BUFF_SIZE
|
protected static org.apache.commons.httpclient.MultiThreadedHttpConnectionManager |
connectionManager
|
protected static java.lang.String |
ENCODING
|
protected static java.lang.String |
FB_SERVER
|
static java.lang.String |
FORMAT_JSON
|
static java.lang.String |
FORMAT_XML
|
protected static java.lang.String |
HTTP_SERVER_ADDR
|
protected static org.apache.commons.httpclient.HttpClient |
httpClient
|
protected static java.lang.String |
HTTPS_SERVER_ADDR
|
protected static org.apache.commons.logging.Log |
log
|
static int |
NUM_AUTOAPPENDED_PARAMS
|
Method Summary | |
---|---|
static java.io.InputStream |
addPhotoTag(Session session,
java.lang.String photoId,
java.lang.String taggedUserId,
java.lang.String tagText,
float x,
float y,
java.lang.String tags,
java.lang.String format,
java.lang.String callback)
|
static java.io.InputStream |
createPhotoAlbum(Session session,
java.lang.String name,
java.lang.String location,
java.lang.String description,
java.lang.String format,
java.lang.String callback)
|
static java.io.InputStream |
feedPublishActionOfUser(Session session,
java.lang.String titleFbml,
java.lang.String bodyFbml,
java.util.Map<java.lang.String,java.lang.String> imageUrlLinkMap,
java.lang.String format,
java.lang.String callback)
Publishes a Mini-Feed story to the user corresponding to the session_key parameter, and publishes News Feed stories to the friends of that user. |
static java.io.InputStream |
feedPublishStoryToUser(Session session,
java.lang.String titleFbml,
java.lang.String bodyFbml,
java.util.Map<java.lang.String,java.lang.String> imageUrlLinkMap,
java.lang.String format,
java.lang.String callback)
Publishes a News Feed story to the user corresponding to the session_key parameter. |
void |
finalize()
|
static java.io.InputStream |
getAppUsers(Session session,
java.lang.String format,
java.lang.String callback)
Returns the identifiers of the current user's Facebook friends who are signed up for the specific calling application. |
static java.lang.String |
getAuthToken(java.lang.String apiKey,
java.lang.String apiSecret)
(Intended for desktop applications only.) Creates an auth_token to be passed in as a parameter to login.php and then to facebook.auth.getSession after the user has logged in. |
static java.io.InputStream |
getEventMembers(Session session,
java.lang.String eventId,
java.lang.String format,
java.lang.String callback)
Returns membership list data associated with an event. |
static java.io.InputStream |
getEvents(Session session,
java.lang.String userId,
java.lang.String[] eventIds,
java.util.Date startTime,
java.util.Date endTime,
java.lang.String rsvpStatusCode,
java.lang.String format,
java.lang.String callback)
Returns all visible events according to the filters specified. |
static java.io.InputStream |
getFqlResultSet(Session session,
java.lang.String fqlQuery,
java.lang.String format,
java.lang.String callback)
Be sure to close the result or you'll leak connections. |
static java.io.InputStream |
getFriends(Session session,
java.lang.String format,
java.lang.String callback)
Returns the identifiers of the current user's Facebook friends. |
static java.io.InputStream |
getFriendsAreFriends(Session session,
java.lang.String[] uids1,
java.lang.String[] uids2,
java.lang.String format,
java.lang.String callback)
|
static java.io.InputStream |
getFriendsAreFriends(Session session,
java.lang.String uids1,
java.lang.String uids2,
java.lang.String format,
java.lang.String callback)
Returns whether or not each pair of specified users is friends with each other. |
static java.io.InputStream |
getGroupMembers(Session session,
java.lang.String groupId,
java.lang.String format,
java.lang.String callback)
Returns membership list data associated with a group. |
static java.io.InputStream |
getGroups(Session session,
java.lang.String userId,
java.lang.String[] groupIds,
java.lang.String format,
java.lang.String callback)
Returns all visible groups according to the filters specified. |
static java.io.InputStream |
getLoggedInUser(Session session,
java.lang.String format,
java.lang.String callback)
Gets the user id (uid) associated with the current sesssion. |
static java.io.InputStream |
getNotifications(Session session,
java.lang.String format,
java.lang.String callback)
Returns information on outstanding Facebook notifications for current session user. |
static java.io.InputStream |
getPhotoAlbums(Session session,
java.lang.String userId,
java.lang.String[] photoIds,
java.lang.String format,
java.lang.String callback)
Returns metadata about all of the photo albums uploaded by the specified user. |
static java.io.InputStream |
getPhotos(Session session,
java.lang.String subjectId,
java.lang.String albumId,
java.lang.String[] photoIds,
java.lang.String format,
java.lang.String callback)
Returns all visible photos according to the filters specified. |
static java.io.InputStream |
getPhotoTags(Session session,
java.lang.String[] photoIds,
java.lang.String format,
java.lang.String callback)
Returns the set of user tags on all photos specified. |
static java.io.InputStream |
getProfileFBML(Session session,
long userId,
java.lang.String format,
java.lang.String callback)
Gets the FBML that is currently set for a user's profile. |
static Session |
getSession(java.lang.String apiKey,
java.lang.String apiSecret,
java.lang.String authToken,
boolean isDesktop)
Get a session for the application's authentication token. |
static java.io.InputStream |
getUsersInfo(Session session,
java.lang.String[] userIds,
java.lang.String[] fields,
java.lang.String format,
java.lang.String callback)
Returns a wide array of user-specific information for each user identifier passed, limited by the view of the current user. |
static java.io.InputStream |
sendNotification(Session session,
java.lang.String[] toUserIds,
java.lang.String notificationFbml,
java.lang.String emailFbml,
java.lang.String format,
java.lang.String callback)
Send a notification to a set of users. |
static java.io.InputStream |
sendNotificationRequest(Session session,
java.lang.String[] toUserIds,
java.lang.String type,
java.lang.String content,
java.lang.String image,
boolean isInvite,
java.lang.String format,
java.lang.String callback)
Send a request or invitation to a set of users. |
static void |
shutdown()
This is the nice way to shut down, and should only be done on system exit. |
static java.io.InputStream |
uploadPhoto(Session session,
java.lang.String albumId,
java.lang.String caption,
java.io.File photo,
java.lang.String format,
java.lang.String callback)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static final org.apache.commons.logging.Log log
protected static final java.lang.String ENCODING
public static final java.lang.String API_VERSION
public static int NUM_AUTOAPPENDED_PARAMS
public static final java.lang.String FORMAT_XML
public static final java.lang.String FORMAT_JSON
protected static final java.lang.String FB_SERVER
protected static final java.lang.String HTTP_SERVER_ADDR
protected static final java.lang.String HTTPS_SERVER_ADDR
protected static final int BUFF_SIZE
protected static org.apache.commons.httpclient.HttpClient httpClient
protected static org.apache.commons.httpclient.MultiThreadedHttpConnectionManager connectionManager
Method Detail |
---|
public static java.lang.String getAuthToken(java.lang.String apiKey, java.lang.String apiSecret) throws java.io.IOException, FacebookException
application
-
java.io.IOException
FacebookException
public static Session getSession(java.lang.String apiKey, java.lang.String apiSecret, java.lang.String authToken, boolean isDesktop) throws java.io.IOException, FacebookException
1) call getAuthToken, to get a valid token
2) call Url.getDesktopLoginUrl(application.getApiKey(), authToken, ...), to generate a login URL
3) present the login URL to the user (as popup?), the user should login
4) user indicates to the app that he's logged in
5) desktop app calls getSession, using the auth_token from step 1)
6) application is updated with a live-session
If this is a webapp, then steps to get session are:
1) call Url.getWebappLoginUrl(application.getApiKey(), ...), to generate a login URL
2) present the login URL to the user (as redirect?), the user should login
3) if Facebook webapp uses a callback url, the user will be redirected there by facebook
4) the auth_token will be presented to the application's url (by redirect to callback or by proxy via canvas page)
5) desktop app calls getSession, using the auth_token from step 4)
6) application is updated with a live-session
If this is a web app, use the token in the GET request from the facebook
redirect after the user logs in. This will be a GET request from the
user's web browser to our website similar to:
http://www.mycompany.com/some/path/callback.html?auth_token=76fa46c30a679e324e21a0b487527b40
Note: this makes it hard to test api_key/secret values for a webapp using
JUnit because the browser will redirect to a live url, not our test url.
However this is possible to test using Jetty and by modifying the hosts
file to point the live webapp url to localhost for testing.
apiKey
- for our applicationauthToken
- for desktop apps the token is created by calling
getAuthToken(apiKey, apiSecret), for webapps it is posted to
our service from Facebook after the user logs inisDesktop
- true if we are using a desktop app, false for webapps
java.io.IOException
- if there's a communication error
FacebookException
- if Facebook doesn't generate the sessionpublic static java.io.InputStream getFriends(Session session, java.lang.String format, java.lang.String callback) throws java.io.IOException, FacebookException
SELECT uid2 FROM friend WHERE uid1=loggedInUid
application
- format
- callback
-
java.io.IOException
FacebookException
public static java.io.InputStream getAppUsers(Session session, java.lang.String format, java.lang.String callback) throws java.io.IOException, FacebookException
application
- format
- callback
-
java.io.IOException
FacebookException
public static java.io.InputStream getNotifications(Session session, java.lang.String format, java.lang.String callback) throws java.io.IOException, FacebookException
application
- format
- callback
-
java.io.IOException
FacebookException
public static java.io.InputStream sendNotification(Session session, java.lang.String[] toUserIds, java.lang.String notificationFbml, java.lang.String emailFbml, java.lang.String format, java.lang.String callback) throws java.io.IOException, FacebookException
application
- toUserIds
- These must be friends of the logged-in user or people who have
added your application.notificationFbml
- FBML for the notifications page.emailFbml
- Optional FBML for the email. If not passed, no email will be
sent.
java.io.IOException
FacebookException
public static java.io.InputStream sendNotificationRequest(Session session, java.lang.String[] toUserIds, java.lang.String type, java.lang.String content, java.lang.String image, boolean isInvite, java.lang.String format, java.lang.String callback) throws java.io.IOException, FacebookException
application
- toUserIds
- These must be friends of the logged-in user or people who have
added your application.type
- The type of request/invitation - e.g. the word "event" in "1
event invitation."content
- Content of the request/invitation. This should be FBML
containing only links and the special tag image
- URL of an image to show beside the request. It will be resized
to be 100 pixels wide.isInvite
- Whether to call this an "invitation" or a "request".format
- callback
-
java.io.IOException
FacebookException
public static java.io.InputStream getUsersInfo(Session session, java.lang.String[] userIds, java.lang.String[] fields, java.lang.String format, java.lang.String callback) throws java.io.IOException, FacebookException
application
- uids
- List of user ids. This is a comma-separated list of user ids.fields
- List of desired fields in return. This is a comma-separated
list of field strings.format
- callback
-
java.io.IOException
FacebookException
public static java.io.InputStream getLoggedInUser(Session session, java.lang.String format, java.lang.String callback) throws java.io.IOException, FacebookException
application
- format
- callback
-
java.io.IOException
FacebookException
public static java.io.InputStream getEvents(Session session, java.lang.String userId, java.lang.String[] eventIds, java.util.Date startTime, java.util.Date endTime, java.lang.String rsvpStatusCode, java.lang.String format, java.lang.String callback) throws java.io.IOException, FacebookException
attending
unsure
declined
not_replied
Privacy note: Event creators will be visible to an application only if
the creator has not turned off access to the Platform or used the
application'; If the creator has opted out , the creator element will
appear in the following format:
<creator xsi:nil="true"/>
application
- userId
- optional filtereventIds
- optional filterstartTime
- optional filterendTime
- optional filterrsvpStatusCode
- optional filterformat
- callback
-
java.io.IOException
FacebookException
public static java.io.InputStream getEventMembers(Session session, java.lang.String eventId, java.lang.String format, java.lang.String callback) throws java.io.IOException, FacebookException
application
- eventId
- Event idformat
- callback
-
java.io.IOException
FacebookException
public static java.io.InputStream getGroups(Session session, java.lang.String userId, java.lang.String[] groupIds, java.lang.String format, java.lang.String callback) throws java.io.IOException, FacebookException
<creator xsi:nil="true"/>
application
- userId
- Optional - Filter by groups associated with a user with this
uidgroupIds
- Optional - Filter by this list of group ids. This is a
comma-separated list of gids.format
- callback
-
java.io.IOException
FacebookException
public static java.io.InputStream getGroupMembers(Session session, java.lang.String groupId, java.lang.String format, java.lang.String callback) throws java.io.IOException, FacebookException
application
- groupId
- Group idformat
- callback
-
java.io.IOException
FacebookException
public static java.io.InputStream getFriendsAreFriends(Session session, java.lang.String[] uids1, java.lang.String[] uids2, java.lang.String format, java.lang.String callback) throws java.io.IOException, FacebookException
java.io.IOException
FacebookException
public static java.io.InputStream getFriendsAreFriends(Session session, java.lang.String uids1, java.lang.String uids2, java.lang.String format, java.lang.String callback) throws java.io.IOException, FacebookException
SELECT uid1, uid2 FROM friend WHERE uid1=uid1 AND uid2=uid2
application
- uids1
- a comma seperated list of UIDsuids2
- a comma seperated list of UIDsformat
- callback
-
java.io.IOException
FacebookException
public static java.io.InputStream getProfileFBML(Session session, long userId, java.lang.String format, java.lang.String callback) throws java.io.IOException, FacebookException
application
- userId
- Optional, the user whose profile FBML is to be fetched. Not
allowed for desktop applications (since the application secret
is essentially public). Use "-1" to exclude, or for desktop
apps.format
- callback
-
java.io.IOException
FacebookException
public static java.io.InputStream feedPublishStoryToUser(Session session, java.lang.String titleFbml, java.lang.String bodyFbml, java.util.Map<java.lang.String,java.lang.String> imageUrlLinkMap, java.lang.String format, java.lang.String callback) throws java.io.IOException, FacebookException
application
- with a valid session representing the app usertitleFbml
- The title is required, and is limited to 60 displayed
characters (excluding tags). The a tag is allowed, and there
can be zero or one instance in the title. No other tags are
allowed.bodyFbml
- optional, limited to 200 displayed characters (excluding
tags), and can include the tags a, b, and i.imageUrlLinkMap
- optional, Up to 4 images can be displayed, which will be
shrunk to fit within 75x75, cached, and formatted by Facebook.
Images can either be a URL, or a facebook PID. If it is a URL,
you must own the image and grant Facebook the permission to
cache it. Each image must have a link associated with it,
which must start with http://format
- callback
-
java.io.IOException
FacebookException
public static java.io.InputStream feedPublishActionOfUser(Session session, java.lang.String titleFbml, java.lang.String bodyFbml, java.util.Map<java.lang.String,java.lang.String> imageUrlLinkMap, java.lang.String format, java.lang.String callback) throws java.io.IOException, FacebookException
application
- with a valid session representing the app usertitleFbml
- The title is required, and is limited to 60 displayed
characters (excluding tags). The a tag is allowed, and there
can be zero or one instance in the title. One fb:userlink tag
is allowed, and the uid parameter must be populated with the
user id on whose behalf the action is being published. If
there is no such fb:userlink tag found, then one is
automatically prepended to the title. The fb:name tag is
allowed, and there may be multiple instances of this tag. No
other tags are allowed.bodyFbml
- The body is optional, is limited to 200 displayed characters
(excluding tags), and can include the tags fb:userlink,
fb:name, a, b, and i.imageUrlLinkMap
- Up to 4 images can be displayed, which will be shrunk to fit
within 75x75, cached, and formatted by Facebook. Images can
either be a URL, or a facebook PID. If it is a URL, you must
own the image and grant Facebook the permission to cache it.
Each image must have a link associated with it, which must
start with http://format
- callback
-
java.io.IOException
FacebookException
public static java.io.InputStream getFqlResultSet(Session session, java.lang.String fqlQuery, java.lang.String format, java.lang.String callback) throws java.io.IOException, FacebookException
application
- query
- format
- optional, XML or JSONcallback
- optional, for XSS
java.io.IOException
FacebookException
public static java.io.InputStream getPhotoAlbums(Session session, java.lang.String userId, java.lang.String[] photoIds, java.lang.String format, java.lang.String callback) throws java.io.IOException, FacebookException
application
- userId
- Optional - Return albums created by this user.photoIds
- Optional - Return albums with aids in this list. This is a
comma-separated list of pids.format
- callback
-
java.io.IOException
FacebookException
public static java.io.InputStream getPhotos(Session session, java.lang.String subjectId, java.lang.String albumId, java.lang.String[] photoIds, java.lang.String format, java.lang.String callback) throws java.io.IOException, FacebookException
application
- subjectId
- Optional - Filter by photos tagged with this useralbumId
- Optional - Filter by photos in this albumphotoIds
- Optional - Filter by photos in this list. This is a
comma-separated list of pids.format
- callback
-
java.io.IOException
FacebookException
public static java.io.InputStream getPhotoTags(Session session, java.lang.String[] photoIds, java.lang.String format, java.lang.String callback) throws java.io.IOException, FacebookException
application
- photoIds
- The list of photos from which to extract photo tags. This is a
comma-separated list of pids.format
- callback
-
java.io.IOException
FacebookException
public static java.io.InputStream addPhotoTag(Session session, java.lang.String photoId, java.lang.String taggedUserId, java.lang.String tagText, float x, float y, java.lang.String tags, java.lang.String format, java.lang.String callback) throws java.io.IOException, FacebookException
application
- photoId
- The photo id of the photo to be tagged.taggedUserId
- The user id of the user being tagged. Either tag_uid or
tag_text must be specified.tagText
- Some text identifying the person being tagged. Either tag_uid
or tag_text must be specified. This parameter is ignored if
tag_uid is specified.x
- The horizontal position of the tag, as a percentage from 0 to
100, from the left of the photo.y
- The vertical position of the tag, as a percentage from 0 to
100, from the top of the photo.tags
- A JSON-serialized array representing a list of tags to be
added to the photo. If the tags parameter is specified, the x,
y, tag_uid, and tag_text parameters are ignored. Each tag in
the list must specify: "x", "y", and either the user id
"tag_uid" or free-form "tag_text" identifying the person being
tagged. An example of this is the string
[{"x":"30.0","y":"30.0","tag_uid":1234567890},
{"x":"70.0","y":"70.0","tag_text":"some person"}]
.format
- callback
-
java.io.IOException
FacebookException
public static java.io.InputStream createPhotoAlbum(Session session, java.lang.String name, java.lang.String location, java.lang.String description, java.lang.String format, java.lang.String callback) throws java.io.IOException, FacebookException
application
- name
- The album name.location
- Optional - The album location.description
- Optional - The album description.format
- callback
-
java.io.IOException
FacebookException
public static java.io.InputStream uploadPhoto(Session session, java.lang.String albumId, java.lang.String caption, java.io.File photo, java.lang.String format, java.lang.String callback) throws java.io.IOException, FacebookException
java.io.IOException
FacebookException
public void finalize() throws java.lang.Throwable
finalize
in class java.lang.Object
java.lang.Throwable
public static void shutdown()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |