Class FaceBookAccess
-
Method Summary
Modifier and TypeMethodDescriptionvoidAdds a response listener on the requestsstatic voidanonymousLogin(String appid, String clientSecret) Some simple queries for public data can work just fine with anonymous login without requiring the whole OAuth process, they still need a facebook application thoughvoidDeletes all temp storage.This method creates a component which can authenticate.voidcreateNote(String userId, String subject, String message) Post a note onto the users wallvoidcreateNote(String userId, String subject, String message, ActionListener callback) Post a note onto the users wallstatic DefaultListModelcreateObjectsModel(DefaultListModel hashtablesModel, Class fbObjectClass) This is a utility method that transforms a DefaultListModel that contains Hashtable entries into a DefaultListModel that will contain FBObject objects that will be initialized with the Hashtable entriesGets a Album from a albumId This is a sync method it will block until a response it returnedvoidgetAlbum(String albumId, Album album, ActionListener<NetworkEvent> callback) Gest an album from an albumIdvoidgetAlbumPhotos(String albumId, DefaultListModel photos, int offset, int limit, ActionListener callback) Gets the albums photosstatic StringReturns the api version used, if empty the non version-ed is usedvoidgetFaceBookObject(String faceBookId, ActionListener<NetworkEvent> callback) This method returns immediately and will call the callback when it returns with the FaceBook Object data.voidgetFaceBookObject(String faceBookId, ActionListener<NetworkEvent> callback, boolean needToken, boolean async) This method returns immediately and will call the callback when it returns with the FaceBook Object data.voidgetFaceBookObjectItems(String faceBookId, String itemsConnection, DefaultListModel feed, Hashtable params, ActionListener callback) Get a list of FaceBook objects for a given idgetImageURL(String id, Dimension toScale) Returns the URL for a given imagestatic FaceBookAccessgets the class instancevoidgetNewsFeed(String userId, DefaultListModel feed, int limit, ActionListener callback) Gets the user news feed, the data is being stored in the given DefaultListModel.voidgetNewsFeed(String userId, DefaultListModel feed, ActionListener callback) Gets the user news feed, the data is being stored in the given DefaultListModel.Gets a Page from a pageId/name This is a sync method it will block until a response it returnedGets a Photo from a photoId This is a sync method it will block until a response it returnedvoidgetPhoto(String photoId, Photo photo, ActionListener<NetworkEvent> callback) Gest a photo from a photo IdvoidgetPhotoThumbnail(String photoId, ActionListener callback, boolean tempStorage) Gets the photo thumbnail of a Photo ObjectvoidgetPhotoThumbnail(String photoId, Label label, Dimension toScale, boolean tempStorage) Gets the photo thumbnail of a Photo ObjectvoidgetPicture(String id, Component targetList, int targetOffset, String targetKey, Dimension toScale, boolean tempStorage) Gets the picture of the given facebook object id and stores it in the given List in the offset indexvoidgetPicture(String id, ActionListener callback, Dimension toScale, boolean tempStorage) Gets the picture of the given facebook object idvoidgetPicture(String id, Label label, Dimension toScale, boolean tempStorage) Gets the picture of the given facebook object idgetPictureAndWait(String id, Dimension toScale) Gets the picture of the given facebook object idGets a Post from a postId This is a sync method it will block until a response it returnedvoidgetPost(String postId, Post post, ActionListener<NetworkEvent> callback) Gest a post from a post IdvoidgetPostComments(String postId, DefaultListModel comments, ActionListener callback) Gets the post commentsstatic StringgetToken()Returns the Facebook authorization token that can be used for API accessGets a User from a user id This is a sync method it will block until a response it returnedvoidgetUser(String userId, User user, ActionListener<NetworkEvent> callback) Gets a user from a user idvoidgetUserAlbums(String userId, DefaultListModel albums, ActionListener callback) Gets the user albumsvoidgetUserEvents(String userId, DefaultListModel events, ActionListener callback) Gets the user eventsvoidgetUserFriends(String userId, DefaultListModel friends, ActionListener callback) Gets the user friendsvoidgetUserInboxThreads(String userId, DefaultListModel threads, int limit, ActionListener callback) Gets the user inbox ThreadsvoidgetUserNotifications(String userId, String startTime, boolean includeRead, DefaultListModel notifications, ActionListener<NetworkEvent> callback) Gets the user notifications (this method uses the legacy rest api see http://developers.facebook.com/docs/reference/rest/)voidgetUsersDetails(String[] usersIds, String[] fields, ActionListener<NetworkEvent> callback) Gets users requested details ((this method uses the legacy rest api see http://developers.facebook.com/docs/reference/rest/))voidgetWallFeed(String userId, DefaultListModel feed, int limit, ActionListener callback) Gets the user wall feed, the data is being stored in the given DefaultListModel.voidgetWallFeed(String userId, DefaultListModel feed, ActionListener callback) Gets the user wall feed, the data is being stored in the given DefaultListModel.voidgetWallPosts(String userId, DefaultListModel feed, int limit, ActionListener callback) Gets the user wall posts, the data is being stored in the given DefaultListModel.voidgetWallPosts(String userId, DefaultListModel feed, ActionListener callback) Gets the user wall feed, the data is being stored in the given DefaultListModel.booleanThis method returns true if the user is authenticated to the facebook service.voidKills the current request.static voidlogOut()log out the current uservoidpostComment(String postId, String message) Post a comment on a given postvoidpostComment(String postId, String message, ActionListener callback) Post a comment on a given postvoidPost like on a given postvoidpostLike(String postId, ActionListener callback) Post like on a given postvoidpostOnWall(String userId, String message) Post a message on the users wallvoidpostOnWall(String userId, String message, ActionListener callback) Post a message on the users wallvoidpostOnWall(String userId, String message, String name, String link, String description, String picture, String caption, ActionListener callback) Post a message on the users wallvoidRemoves a response listenervoidsearch(String objectType, String query, DefaultListModel results, ActionListener callback) Serach for facebook objectsstatic voidsetApiVersion(String apiVersion) Sets the Facebook api version being used, by default the api calls the non version-ed version of the API.static voidsetClientId(String clientId) The client id (appid) which asks to connect (this is generated when an app is created see: https://developers.facebook.com/apps)static voidsetClientSecret(String clientSecret) The client secret is been generated by facebook see: https://developers.facebook.com/appsstatic voidsetPermissions(String[] permissions) The requested permissions of the app http://developers.facebook.com/docs/reference/api/permissions/voidsetProgress(Slider slider) Sets the progress indicator to get network updates on the queriesstatic voidsetRedirectURI(String redirectURI) This is generated when an app is created see: https://developers.facebook.com/appsstatic voidSets the token to the FaceBookAccess class, this is useful if the token has not yet expired, get the expiration of the token with Oauth2.getExpires()voidThis method shows an authentication for login form
-
Method Details
-
getInstance
gets the class instance
Returns
a FaceBookAccess object
-
createObjectsModel
public static DefaultListModel createObjectsModel(DefaultListModel hashtablesModel, Class fbObjectClass) throws IllegalAccessException, InstantiationException This is a utility method that transforms a DefaultListModel that contains Hashtable entries into a DefaultListModel that will contain FBObject objects that will be initialized with the Hashtable entries
Parameters
-
hashtablesModel: the model to transform, this model should hold it's data has Hashtable entries -
fbObjectClass: this is the class of the entries to be created, this class should be a FBObject type
Returns
a DefaultListModel with fbObjectClass objects entries
Throws
-
IllegalAccessException: if the fbObjectClass.newInstance() fails -
InstantiationExceptionif: the fbObjectClass.newInstance() fails
-
-
setClientId
The client id (appid) which asks to connect (this is generated when an app is created see: https://developers.facebook.com/apps)
Parameters
clientId
-
setClientSecret
The client secret is been generated by facebook see: https://developers.facebook.com/apps
Parameters
clientSecret
-
setPermissions
The requested permissions of the app http://developers.facebook.com/docs/reference/api/permissions/
Parameters
permissions
-
setRedirectURI
This is generated when an app is created see: https://developers.facebook.com/apps
Parameters
redirectURI
-
getToken
Returns the Facebook authorization token that can be used for API access
Returns
the token
-
setToken
Sets the token to the FaceBookAccess class, this is useful if the token has not yet expired, get the expiration of the token with Oauth2.getExpires()
Parameters
tok: the token of the
-
logOut
public static void logOut()log out the current user -
anonymousLogin
Some simple queries for public data can work just fine with anonymous login without requiring the whole OAuth process, they still need a facebook application though
Parameters
-
appid: the id of the application -
clientSecret: the client secret for the application
-
-
getApiVersion
Returns the api version used, if empty the non version-ed is used -
setApiVersion
Sets the Facebook api version being used, by default the api calls the non version-ed version of the API.
Parameters
apiVersion: valid values are "1.0", "2.0", "2.1"
-
createOAuth
-
createAuthComponent
This method creates a component which can authenticate. You will receive either the authentication key or an Exception object within the ActionListener callback method.
Parameters
al: a listener that will receive at its source either a token for the service or an exception in case of a failure
Returns
a component that should be displayed to the user in order to perform the authentication
-
showAuthentication
This method shows an authentication for login form
Parameters
al: @param al a listener that will receive at its source either a token for the service or an exception in case of a failure
-
isAuthenticated
public boolean isAuthenticated()This method returns true if the user is authenticated to the facebook service.
Returns
true if authenticated
-
setProgress
Sets the progress indicator to get network updates on the queries
Parameters
slider
-
getFaceBookObject
public void getFaceBookObject(String faceBookId, ActionListener<NetworkEvent> callback) throws IOException This method returns immediately and will call the callback when it returns with the FaceBook Object data.
Parameters
-
faceBookId: the object id that we would like to query -
callback: the callback that should be updated when the data arrives
- Throws:
IOException
-
-
getFaceBookObject
public void getFaceBookObject(String faceBookId, ActionListener<NetworkEvent> callback, boolean needToken, boolean async) throws IOException This method returns immediately and will call the callback when it returns with the FaceBook Object data.
Parameters
-
faceBookId: the object id that we would like to query -
callback: the callback that should be updated when the data arrives -
needToken: if true authentication is being checked
- Throws:
IOException
-
-
getFaceBookObjectItems
public void getFaceBookObjectItems(String faceBookId, String itemsConnection, DefaultListModel feed, Hashtable params, ActionListener callback) throws IOException Get a list of FaceBook objects for a given id
Parameters
-
faceBookId: the id to preform the query upon -
itemsConnection: the type of the query -
feed -
params -
callback: the callback that should be updated when the data arrives
- Throws:
IOException
-
-
getUser
public void getUser(String userId, User user, ActionListener<NetworkEvent> callback) throws IOException Gets a user from a user id
Parameters
-
userId: the user id or null to get detaild on the authenticated user -
user: an object to fill with the user details -
callback: the callback that should be updated when the data arrives
- Throws:
IOException
-
-
getUser
Gets a User from a user id This is a sync method it will block until a response it returned
Parameters
userId: the user id or null to get details on the authenticated user
Returns
the User requested
- Throws:
IOException
-
getPage
Gets a Page from a pageId/name This is a sync method it will block until a response it returned
Parameters
pageId: the pageId
Returns
the Page requested
- Throws:
IOException
-
getPost
public void getPost(String postId, Post post, ActionListener<NetworkEvent> callback) throws IOException Gest a post from a post Id
Parameters
-
postId: the postId -
post: an Object to fill with the data -
callback: the callback that should be updated when the data arrives
- Throws:
IOException
-
-
getPost
Gets a Post from a postId This is a sync method it will block until a response it returned
Parameters
-
postId: the post id -
needAuth: @param needAuth if this object is public needAuth can be false and no authentication will be performed
Returns
the Post requested
- Throws:
IOException
-
-
getPhoto
public void getPhoto(String photoId, Photo photo, ActionListener<NetworkEvent> callback) throws IOException Gest a photo from a photo Id
Parameters
-
photoId: the photoId -
photo: an Object to fill with the data -
callback: the callback that should be updated when the data arrives
- Throws:
IOException
-
-
getPhoto
Gets a Photo from a photoId This is a sync method it will block until a response it returned
Parameters
-
photoId: the photoId -
needAuth: @param needAuth if this object is public needAuth can be false and no authentication will be performed
Returns
the Photo requested
- Throws:
IOException
-
-
getAlbum
public void getAlbum(String albumId, Album album, ActionListener<NetworkEvent> callback) throws IOException Gest an album from an albumId
Parameters
-
albumId: the albumId -
album: an Object to fill with the data -
callback: the callback that should be updated when the data arrives
- Throws:
IOException
-
-
getAlbum
Gets a Album from a albumId This is a sync method it will block until a response it returned
Parameters
-
albumId: the albumId -
needAuth: @param needAuth if this object is public needAuth can be false and no authentication will be performed
Returns
the Album requested
- Throws:
IOException
-
-
getNewsFeed
public void getNewsFeed(String userId, DefaultListModel feed, ActionListener callback) throws IOException Gets the user news feed, the data is being stored in the given DefaultListModel. By default this method will return last 13 news entries.
Parameters
-
userId: the userid we would like to query -
feed: the response to fill -
callback: the callback that should be updated when the data arrives
- Throws:
IOException
-
-
getNewsFeed
public void getNewsFeed(String userId, DefaultListModel feed, int limit, ActionListener callback) throws IOException Gets the user news feed, the data is being stored in the given DefaultListModel.
Parameters
-
userId: the userid we would like to query -
feed: the response to fill -
limit: the number of items to return -
callback: the callback that should be updated when the data arrives
- Throws:
IOException
-
-
getWallFeed
public void getWallFeed(String userId, DefaultListModel feed, ActionListener callback) throws IOException Gets the user wall feed, the data is being stored in the given DefaultListModel. By default this method will return last 13 news entries.
Parameters
-
userId: the userid we would like to query -
feed: the response fo fill -
callback: the callback that should be updated when the data arrives
- Throws:
IOException
-
-
getWallFeed
public void getWallFeed(String userId, DefaultListModel feed, int limit, ActionListener callback) throws IOException Gets the user wall feed, the data is being stored in the given DefaultListModel.
Parameters
-
userId: the userid we would like to query -
feed: the response to fill -
limit: the number of items to return -
callback: the callback that should be updated when the data arrives
- Throws:
IOException
-
-
getWallPosts
public void getWallPosts(String userId, DefaultListModel feed, ActionListener callback) throws IOException Gets the user wall feed, the data is being stored in the given DefaultListModel. By default this method will return last 13 news entries.
Parameters
-
userId: the userid we would like to query -
feed: the response fo fill -
callback: the callback that should be updated when the data arrives
- Throws:
IOException
-
-
getWallPosts
public void getWallPosts(String userId, DefaultListModel feed, int limit, ActionListener callback) throws IOException Gets the user wall posts, the data is being stored in the given DefaultListModel.
Parameters
-
userId: the userid we would like to query -
feed: the response to fill -
limit: the number of items to return -
callback: the callback that should be updated when the data arrives
- Throws:
IOException
-
-
getPicture
public void getPicture(String id, Label label, Dimension toScale, boolean tempStorage) throws IOException Gets the picture of the given facebook object id
Parameters
-
id: the object id to query -
label: place the image on the given label as an icon -
toScale: scale the image to the given dimension -
tempStorage: if true place the image in a temp storage
- Throws:
IOException
-
-
getPicture
public void getPicture(String id, ActionListener callback, Dimension toScale, boolean tempStorage) throws IOException Gets the picture of the given facebook object id
Parameters
-
id: the object id to query -
callback: the callback that should be updated when the data arrives -
toScale: picture dimension or null -
tempStorage: if true place the image in a temp storage
- Throws:
IOException
-
-
getPictureAndWait
Gets the picture of the given facebook object id
Parameters
-
id: the object id to query -
toScale: picture dimension or null
Returns
the picture
-
-
getImageURL
-
getPicture
public void getPicture(String id, Component targetList, int targetOffset, String targetKey, Dimension toScale, boolean tempStorage) throws IOException Gets the picture of the given facebook object id and stores it in the given List in the offset index
This assumes the GenericListCellRenderer style of list which relies on a hashtable based model approach.
Parameters
-
id: the object id to query -
targetList: the list that should be updated when the data arrives -
targetOffset: the offset within the list to insert the image -
targetKey: the key for the hashtable in the target offset -
toScale: the scale of the image to put in the List or null -
tempStorage: if true place the image in a temp storage
- Throws:
IOException
-
-
getPhotoThumbnail
public void getPhotoThumbnail(String photoId, ActionListener callback, boolean tempStorage) throws IOException Gets the photo thumbnail of a Photo Object
Parameters
-
photoId: the photo id -
callback: the callback that should be updated when the data arrives -
tempStorage: if true place the image in a temp storage
- Throws:
IOException
-
-
getPhotoThumbnail
public void getPhotoThumbnail(String photoId, Label label, Dimension toScale, boolean tempStorage) throws IOException Gets the photo thumbnail of a Photo Object
Parameters
-
photoId: the photo id -
label: place the image on the given label as an icon -
toScale: scale the image to the given dimension -
tempStorage: if true place the image in a temp storage
- Throws:
IOException
-
-
getUserFriends
public void getUserFriends(String userId, DefaultListModel friends, ActionListener callback) throws IOException Gets the user friends
Parameters
-
userId: the id -
friends: @param friends store friends results into the given model, each entry is an Hashtable Object contaning the Object data -
callback: the callback that should be updated when the data arrives
- Throws:
IOException
-
-
getUserAlbums
public void getUserAlbums(String userId, DefaultListModel albums, ActionListener callback) throws IOException Gets the user albums
Parameters
-
userId: the id -
albums: @param albums store albums results into the given model, each entry is an Hashtable Object contaning the Object data -
callback: the callback that should be updated when the data arrives
- Throws:
IOException
-
-
getAlbumPhotos
public void getAlbumPhotos(String albumId, DefaultListModel photos, int offset, int limit, ActionListener callback) throws IOException Gets the albums photos
Parameters
-
albumId: the id -
photos: @param photos store photos results into the given model, each entry is an Hashtable Object contaning the Object data -
offset: the offset of the photo in the album -
limit: amount of photos to bring -
callback: the callback that should be updated when the data arrives
- Throws:
IOException
-
-
getPostComments
public void getPostComments(String postId, DefaultListModel comments, ActionListener callback) throws IOException Gets the post comments
Parameters
-
postId: the id -
comments: @param comments store comments results into the given model, each entry is an Hashtable Object contaning the Object data -
callback: the callback that should be updated when the data arrives
- Throws:
IOException
-
-
getUserInboxThreads
public void getUserInboxThreads(String userId, DefaultListModel threads, int limit, ActionListener callback) throws IOException Gets the user inbox Threads
Parameters
-
userId: the id -
threads: @param threads store threads results into the given model, each entry is an Hashtable Object contaning the Object data -
limit: the amount of thread to return -
callback: the callback that should be updated when the data arrives
- Throws:
IOException
-
-
postOnWall
Post a message on the users wall
Parameters
-
userId: the userId -
message: the message to post
- Throws:
IOException
-
-
postLike
Post like on a given post
Parameters
postId: the post Id
- Throws:
IOException
-
postComment
Post a comment on a given post
Parameters
-
postId: the post id -
message: the message to post
- Throws:
IOException
-
-
createNote
Post a note onto the users wall
Parameters
-
userId: the userId -
message: the message to post
- Throws:
IOException
-
-
postOnWall
Post a message on the users wall
Parameters
-
userId: the userId -
message: the message to post
- Throws:
IOException
-
-
postOnWall
public void postOnWall(String userId, String message, String name, String link, String description, String picture, String caption, ActionListener callback) throws IOException Post a message on the users wall
Parameters
-
userId: the userId -
message: the message to post -
name -
link -
description -
picture -
caption
- Throws:
IOException
-
-
postLike
Post like on a given post
Parameters
postId: the post Id
- Throws:
IOException
-
postComment
Post a comment on a given post
Parameters
-
postId: the post id -
message: the message to post
- Throws:
IOException
-
-
createNote
public void createNote(String userId, String subject, String message, ActionListener callback) throws IOException Post a note onto the users wall
Parameters
-
userId: the userId -
message: the message to post
- Throws:
IOException
-
-
getUserNotifications
public void getUserNotifications(String userId, String startTime, boolean includeRead, DefaultListModel notifications, ActionListener<NetworkEvent> callback) throws IOException Gets the user notifications (this method uses the legacy rest api see http://developers.facebook.com/docs/reference/rest/)
Parameters
-
userId: the user id -
startTime: @param startTime Indicates the earliest time to return a notification. This equates to the updated_time field in the notification FQL table. If not specified, this call returns all available notifications. -
includeRead: @param includeRead Indicates whether to include notifications that have already been read. By default, notifications a user has read are not included. -
notifications: @param notifications store notifications results into the given model, each entry is an Hashtable Object contaning the Object data -
callback: the callback that should be updated when the data arrives
- Throws:
IOException
-
-
getUsersDetails
public void getUsersDetails(String[] usersIds, String[] fields, ActionListener<NetworkEvent> callback) throws IOException Gets users requested details ((this method uses the legacy rest api see http://developers.facebook.com/docs/reference/rest/))
Parameters
-
usersIds: the users to query -
fields: which fields to query on the users see http://developers.facebook.com/docs/reference/rest/users.getInfo/ -
callback: @param callback the result will call the callback with the result to extrct the data preform the following: public void actionPerformed(ActionEvent evt) { Vector data = (Vector) ((NetworkEvent) evt).getMetaData(); Vector users = (Vector) data.elementAt(0); }
- Throws:
IOException
-
-
getUserEvents
public void getUserEvents(String userId, DefaultListModel events, ActionListener callback) throws IOException Gets the user events
Parameters
-
userId: the user id -
events: @param events store events results into the given model, each entry is an Hashtable Object contaning the Object data -
callback: the callback that should be updated when the data arrives
- Throws:
IOException
-
-
search
public void search(String objectType, String query, DefaultListModel results, ActionListener callback) throws IOException Serach for facebook objects
Parameters
-
objectType: one of each: post, user, page, event, group, place, checkin -
query: the query string to search for -
results: @param results store results onto the given model, each entry is an Hashtable Object contaning the Object data -
callback: the callback that should be updated when the data arrives
- Throws:
IOException
-
-
killCurrentRequest
public void killCurrentRequest()Kills the current request. -
addResponseCodeListener
Adds a response listener on the requests
Parameters
a: response listener
-
removeResponseCodeListener
Removes a response listener -
cleanTempStorage
public void cleanTempStorage()Deletes all temp storage.
-