net.sf.f8api
Class FacebookApi

java.lang.Object
  extended by net.sf.f8api.FacebookApi

public class FacebookApi
extends java.lang.Object

Stateless communication interface.

Author:
Jason Thrasher

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

log

protected static final org.apache.commons.logging.Log log

ENCODING

protected static final java.lang.String ENCODING
See Also:
Constant Field Values

API_VERSION

public static final java.lang.String API_VERSION
See Also:
Constant Field Values

NUM_AUTOAPPENDED_PARAMS

public static int NUM_AUTOAPPENDED_PARAMS

FORMAT_XML

public static final java.lang.String FORMAT_XML
See Also:
Constant Field Values

FORMAT_JSON

public static final java.lang.String FORMAT_JSON
See Also:
Constant Field Values

FB_SERVER

protected static final java.lang.String FB_SERVER
See Also:
Constant Field Values

HTTP_SERVER_ADDR

protected static final java.lang.String HTTP_SERVER_ADDR
See Also:
Constant Field Values

HTTPS_SERVER_ADDR

protected static final java.lang.String HTTPS_SERVER_ADDR
See Also:
Constant Field Values

BUFF_SIZE

protected static final int BUFF_SIZE
See Also:
Constant Field Values

httpClient

protected static org.apache.commons.httpclient.HttpClient httpClient

connectionManager

protected static org.apache.commons.httpclient.MultiThreadedHttpConnectionManager connectionManager
Method Detail

getAuthToken

public static java.lang.String getAuthToken(java.lang.String apiKey,
                                            java.lang.String apiSecret)
                                     throws java.io.IOException,
                                            FacebookException
(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. The user must log in soon after you create this token. See the authentication guide for more information.

Parameters:
application -
Returns:
Throws:
java.io.IOException
FacebookException

getSession

public static Session getSession(java.lang.String apiKey,
                                 java.lang.String apiSecret,
                                 java.lang.String authToken,
                                 boolean isDesktop)
                          throws java.io.IOException,
                                 FacebookException
Get a session for the application's authentication token. If successful the application will be updated with session information for use in future calls. If this is a desktop app, then steps to get a session are: 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.

Parameters:
apiKey - for our application
authToken - 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 in
isDesktop - true if we are using a desktop app, false for webapps
Returns:
an active session
Throws:
java.io.IOException - if there's a communication error
FacebookException - if Facebook doesn't generate the session

getFriends

public static java.io.InputStream getFriends(Session session,
                                             java.lang.String format,
                                             java.lang.String callback)
                                      throws java.io.IOException,
                                             FacebookException
Returns the identifiers of the current user's Facebook friends. The current user is determined from the session_key parameter. The values returned from this call are not storable. Response Privacy Note : The friend ids returned are those friends visible to the Facebook Platform. If no friends are found, the method will return an empty friends_get_response element. FQL Equivalent: This function is similar to doing the following FQL query, with the appropriate parameters filled in: SELECT uid2 FROM friend WHERE uid1=loggedInUid

Parameters:
application -
format -
callback -
Returns:
Throws:
java.io.IOException
FacebookException

getAppUsers

public static java.io.InputStream getAppUsers(Session session,
                                              java.lang.String format,
                                              java.lang.String callback)
                                       throws java.io.IOException,
                                              FacebookException
Returns the identifiers of the current user's Facebook friends who are signed up for the specific calling application. The current user is determined from the session_key parameter. The values returned from this call are not storable.

Parameters:
application -
format -
callback -
Returns:
Throws:
java.io.IOException
FacebookException

getNotifications

public static java.io.InputStream getNotifications(Session session,
                                                   java.lang.String format,
                                                   java.lang.String callback)
                                            throws java.io.IOException,
                                                   FacebookException
Returns information on outstanding Facebook notifications for current session user.

Parameters:
application -
format -
callback -
Returns:
Throws:
java.io.IOException
FacebookException

sendNotification

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
Send a notification to a set of users. You can send emails to users that have added the application without any confirmation, or you can direct a user of your application to the URL returned by this function to email users who have not yet added your application. You can also send messages to the user's notification page without needing any confirmation. The notification and email parameters are a very stripped-down set of FBML which allows only tags that result in just text and links, and in the email, linebreaks. There is one additional tag supported within the email parameter - use fb:notif-subject around the subject of the email.

Parameters:
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.
Returns:
If a URL is returned, redirect the user to that URL to confirm sending of the notification. If no URL is returned, either an error occurred or the message went through without requiring confirmation. We will eventually support some additional error codes for the error case.
Throws:
java.io.IOException
FacebookException

sendNotificationRequest

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
Send a request or invitation to a set of users. You can send requests to users that have added the application without any confirmation, or you can direct a user of your application to the URL returned by this function to send requests to users who have not yet added your application.

Parameters:
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 to specify the buttons to be included in the request.
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 -
Returns:
If a URL is returned, redirect the user to that URL to confirm sending of the request. If no URL is returned, either an error occurred or the request went through without requiring confirmation. We will eventually support some additional error codes for the error case.
Throws:
java.io.IOException
FacebookException

getUsersInfo

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
Returns a wide array of user-specific information for each user identifier passed, limited by the view of the current user. The current user is determined from the session_key parameter. The only storable values returned from this call are the those under the affiliations element, the notes_count value, and the contents of the profile_update_time element.

Parameters:
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 -
Returns:
The user info elements returned are those friends visible to the Facebook Platform. If no visible users are found from the passed uids argument, the method will return an empty result element.
Throws:
java.io.IOException
FacebookException
See Also:
docs

getLoggedInUser

public static java.io.InputStream getLoggedInUser(Session session,
                                                  java.lang.String format,
                                                  java.lang.String callback)
                                           throws java.io.IOException,
                                                  FacebookException
Gets the user id (uid) associated with the current sesssion. This value should be stored for the duration of the session, to avoid unnecessary subsequent calls to this method. The same value is also returned by facebook.auth.getSession.

Parameters:
application -
format -
callback -
Returns:
Throws:
java.io.IOException
FacebookException

getEvents

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
Returns all visible events according to the filters specified. This may be used to find all events of a user, or to query specific eids. This method returns all events satisfying the filters specified. The method can be used to return all events associated with user, or query a specific set of events by a list of eids. If both the uid and eids parameters are provided, the method returns all events in the set of eids, with which the user is associated. If the eids parameter is omitted, the method returns all events associated with the provided user. If, instead, the uid parameter is omitted, the method returns all events associted with the provided eids, regardless of any user relationship. If both parameters are omitted, the method returns all events associated with the session user. start_time and end_time parameters specify a (possibly open-ended) window which all events returned will overlap. Note that if start_time is greater than or equal to end_time, an empty top-level element is returned. The RSVP status should be one of the following strings:

 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"/>
 

Parameters:
application -
userId - optional filter
eventIds - optional filter
startTime - optional filter
endTime - optional filter
rsvpStatusCode - optional filter
format -
callback -
Returns:
Events are only visible if they are not secret. If no such events are found, the method will return an empty events_get_response element. The nid field will be 0 for global events.
Throws:
java.io.IOException
FacebookException

getEventMembers

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
Returns membership list data associated with an event. Privacy note: The lists can contain uids of users not using the calling application.

Parameters:
application -
eventId - Event id
format -
callback -
Returns:
This method returns four (possibly empty) lists of users associated with an event, keyed on their associations. These lists should never share any members.
Throws:
java.io.IOException
FacebookException

getGroups

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
Returns all visible groups according to the filters specified. This may be used to find all groups of which a user is as member, or to query specific gids. This method returns all groups satisfying the filters specified. The method can be used to return all groups associated with user, or query a specific set of events by a list of gids. If both the uid and gids parameters are provided, the method returns all groups in the set of gids, with which the user is associated. If the gids parameter is omitted, the method returns all groups associated with the provided user. If, instead, the uid parameter is omitted, the method returns all groups associted with the provided gids, regardless of any user relationship. If both parameters are omitted, the method returns all groups of the session user. Privacy note: Group 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"/>
 

Parameters:
application -
userId - Optional - Filter by groups associated with a user with this uid
groupIds - Optional - Filter by this list of group ids. This is a comma-separated list of gids.
format -
callback -
Returns:
Groups are only visible if they are not secret. If no such groups are found, the method will return an empty groups_get_response element. The nid field will be 0 for global groups.
Throws:
java.io.IOException
FacebookException

getGroupMembers

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
Returns membership list data associated with a group. Privacy note: The lists can contain uids of users not using the calling application.

Parameters:
application -
groupId - Group id
format -
callback -
Returns:
This method returns four (possibly empty) lists of users associated with a group, keyed on their associations. The members list will contain the officers and admins lists, but will not overlap with the not_replied list.
Throws:
java.io.IOException
FacebookException

getFriendsAreFriends

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
Throws:
java.io.IOException
FacebookException

getFriendsAreFriends

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
Returns whether or not each pair of specified users is friends with each other. The first array specifies one half of each pair, the second array the other half; therefore, they must be of equal size. FQL Equivalent This function is similar to doing the following FQL query, with the appropriate parameters filled in: SELECT uid1, uid2 FROM friend WHERE uid1=uid1 AND uid2=uid2

Parameters:
application -
uids1 - a comma seperated list of UIDs
uids2 - a comma seperated list of UIDs
format -
callback -
Returns:
Throws:
java.io.IOException
FacebookException

getProfileFBML

public static java.io.InputStream getProfileFBML(Session session,
                                                 long userId,
                                                 java.lang.String format,
                                                 java.lang.String callback)
                                          throws java.io.IOException,
                                                 FacebookException
Gets the FBML that is currently set for a user's profile. See the FBML documentation for a description of the markup and its role in various contexts.

Parameters:
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 -
Returns:
Throws:
java.io.IOException
FacebookException

feedPublishStoryToUser

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
Publishes a News Feed story to the user corresponding to the session_key parameter. The function returns 1 on success, 0 on permissions error, or otherwise an error response.Publishing to News Feed requires understanding rules of its operation. Applications are limited to calling this function once every 12 hours for each user. The story may or may not show up in the user's News Feed, depending on the number and quality of competing stories. Developer Note: If an app developer calls feed.publishStoryToUser for his own user id, the story is always published. This is to allow for testing and display tweaks.

Parameters:
application - with a valid session representing the app user
titleFbml - 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 -
Returns:
Throws:
java.io.IOException
FacebookException

feedPublishActionOfUser

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
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. Applications are limited to calling this function ten (10) times for each user in a rolling 48-hour window. The story may or may not show up in the user's friends' News Feeds, depending on the number and quality of competing stories. Developer Note: Unlike feed_publishStoryToUser, there is no unlimited rule for feed_publishActionOfUser, since this method affects all Facebook friends of the developer.

Parameters:
application - with a valid session representing the app user
titleFbml - 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 -
Returns:
Throws:
java.io.IOException
FacebookException

getFqlResultSet

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
Be sure to close the result or you'll leak connections.

Parameters:
application -
query -
format - optional, XML or JSON
callback - optional, for XSS
Returns:
result set, (be sure to close the stream or you'll leak connections)
Throws:
java.io.IOException
FacebookException
See Also:
FQL Reference

getPhotoAlbums

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
Returns metadata about all of the photo albums uploaded by the specified user. The values returned from this call are not storable. This method returns all visible photos satisfying the filters specified. The method can be used to return all photo albums created by a user, query a specific set of albums by a list of aids, or filter on any combination of these two. It is an error to omit both of the uid and aids parameters. They have no defaults.

Parameters:
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 -
Returns:
Throws:
java.io.IOException
FacebookException
See Also:
facebook.photos.getAlbums

getPhotos

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
Returns all visible photos according to the filters specified. This may be used to find all photos in which a user is tagged, return photos in a specific album, or to query specific pids. This method returns all visible photos satisfying the filters specified. The method can be used to return all photos tagged with user, in an album, query a specific set of photos by a list of pids, or filter on any combination of these three. It is an error to omit all three of the subj_id, aid, and pids parameters. They have no defaults. Privacy note: Photos will be visible on the Facebook Platform only if the photo owner has not turned off access to the Platform

Parameters:
application -
subjectId - Optional - Filter by photos tagged with this user
albumId - Optional - Filter by photos in this album
photoIds - Optional - Filter by photos in this list. This is a comma-separated list of pids.
format -
callback -
Returns:
Throws:
java.io.IOException
FacebookException
See Also:
facebook.photos.get

getPhotoTags

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
Returns the set of user tags on all photos specified. Privacy note: A tag of a user will be visible to an application only if that user has not turned off access to the Facebook Platform.

Parameters:
application -
photoIds - The list of photos from which to extract photo tags. This is a comma-separated list of pids.
format -
callback -
Returns:
If no photo tags are found, the method will return an empty photos_getTags_response element. Text tags not corresponding to a user are not currently returned.
Throws:
java.io.IOException
FacebookException
See Also:
facebook.photos.getTags

addPhotoTag

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
Parameters:
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 -
Returns:
Throws:
java.io.IOException
FacebookException
See Also:
facebook.photos.addTag

createPhotoAlbum

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
Parameters:
application -
name - The album name.
location - Optional - The album location.
description - Optional - The album description.
format -
callback -
Returns:
The returned cover_pid is always 0.
Throws:
java.io.IOException
FacebookException
See Also:
facebook.photos.createAlbum

uploadPhoto

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
Throws:
java.io.IOException
FacebookException

finalize

public void finalize()
              throws java.lang.Throwable
Overrides:
finalize in class java.lang.Object
Throws:
java.lang.Throwable

shutdown

public static void shutdown()
This is the nice way to shut down, and should only be done on system exit.



Copyright © 2007 Jason Thrasher. All Rights Reserved.