public class FaceBookAccess extends Object
Modifier and Type | Method and Description |
---|---|
void |
addResponseCodeListener(ActionListener a)
Adds a response listener on the requests
|
static void |
anonymousLogin(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 though
|
void |
cleanTempStorage()
Deletes all temp storage.
|
Component |
createAuthComponent(ActionListener al)
This method creates a component which can authenticate.
|
void |
createNote(String userId,
String subject,
String message)
Post a note onto the users wall
|
void |
createNote(String userId,
String subject,
String message,
ActionListener callback)
Post a note onto the users wall
|
Oauth2 |
createOAuth() |
static DefaultListModel |
createObjectsModel(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 entries
|
void |
getAlbum(String albumId,
Album album,
ActionListener callback)
Gest an album from an albumId
|
Album |
getAlbum(String albumId,
boolean needAuth)
Gets a Album from a albumId
This is a sync method it will block until a response it returned
|
void |
getAlbumPhotos(String albumId,
DefaultListModel photos,
int offset,
int limit,
ActionListener callback)
Gets the albums photos
|
static String |
getApiVersion()
Returns the api version used, if empty the non version-ed is used
|
void |
getFaceBookObject(String faceBookId,
ActionListener callback)
This method returns immediately and will call the callback when it returns with
the FaceBook Object data.
|
void |
getFaceBookObject(String faceBookId,
ActionListener callback,
boolean needToken,
boolean async)
This method returns immediately and will call the callback when it returns with
the FaceBook Object data.
|
void |
getFaceBookObjectItems(String faceBookId,
String itemsConnection,
DefaultListModel feed,
Hashtable params,
ActionListener callback)
Get a list of FaceBook objects for a given id
|
String |
getImageURL(String id,
Dimension toScale)
Returns the URL for a given image
|
static FaceBookAccess |
getInstance()
gets the class instance
|
void |
getNewsFeed(String userId,
DefaultListModel feed,
ActionListener callback)
Gets the user news feed, the data is being stored in the given DefaultListModel.
|
void |
getNewsFeed(String userId,
DefaultListModel feed,
int limit,
ActionListener callback)
Gets the user news feed, the data is being stored in the given DefaultListModel.
|
Page |
getPage(String pageId)
Gets a Page from a pageId/name
This is a sync method it will block until a response it returned
|
Photo |
getPhoto(String photoId,
boolean needAuth)
Gets a Photo from a photoId
This is a sync method it will block until a response it returned
|
void |
getPhoto(String photoId,
Photo photo,
ActionListener callback)
Gest a photo from a photo Id
|
void |
getPhotoThumbnail(String photoId,
ActionListener callback,
boolean tempStorage)
Gets the photo thumbnail of a Photo Object
|
void |
getPhotoThumbnail(String photoId,
Label label,
Dimension toScale,
boolean tempStorage)
Gets the photo thumbnail of a Photo Object
|
void |
getPicture(String id,
ActionListener callback,
Dimension toScale,
boolean tempStorage)
Gets the picture of the given facebook object id
|
void |
getPicture(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 index
This assumes the GenericListCellRenderer style of
list which relies on a hashtable based model approach.
|
void |
getPicture(String id,
Label label,
Dimension toScale,
boolean tempStorage)
Gets the picture of the given facebook object id
|
EncodedImage |
getPictureAndWait(String id,
Dimension toScale)
Gets the picture of the given facebook object id
|
Post |
getPost(String postId,
boolean needAuth)
Gets a Post from a postId
This is a sync method it will block until a response it returned
|
void |
getPost(String postId,
Post post,
ActionListener callback)
Gest a post from a post Id
|
void |
getPostComments(String postId,
DefaultListModel comments,
ActionListener callback)
Gets the post comments
|
static String |
getToken()
Returns the Facebook authorization token that can be used for API access
|
User |
getUser(String userId)
Gets a User from a user id
This is a sync method it will block until a response it returned
|
void |
getUser(String userId,
User user,
ActionListener callback)
Gets a user from a user id
|
void |
getUserAlbums(String userId,
DefaultListModel albums,
ActionListener callback)
Gets the user albums
|
void |
getUserEvents(String userId,
DefaultListModel events,
ActionListener callback)
Gets the user events
|
void |
getUserFriends(String userId,
DefaultListModel friends,
ActionListener callback)
Gets the user friends
|
void |
getUserInboxThreads(String userId,
DefaultListModel threads,
int limit,
ActionListener callback)
Gets the user inbox Threads
|
void |
getUserNotifications(String userId,
String startTime,
boolean includeRead,
DefaultListModel notifications,
ActionListener callback)
Gets the user notifications (this method uses the legacy rest api see http://developers.facebook.com/docs/reference/rest/)
|
void |
getUsersDetails(String[] usersIds,
String[] fields,
ActionListener callback)
Gets users requested details ((this method uses the legacy rest api see http://developers.facebook.com/docs/reference/rest/))
|
void |
getWallFeed(String userId,
DefaultListModel feed,
ActionListener callback)
Gets the user wall feed, the data is being stored in the given DefaultListModel.
|
void |
getWallFeed(String userId,
DefaultListModel feed,
int limit,
ActionListener callback)
Gets the user wall feed, the data is being stored in the given DefaultListModel.
|
void |
getWallPosts(String userId,
DefaultListModel feed,
ActionListener callback)
Gets the user wall feed, the data is being stored in the given DefaultListModel.
|
void |
getWallPosts(String userId,
DefaultListModel feed,
int limit,
ActionListener callback)
Gets the user wall posts, the data is being stored in the given DefaultListModel.
|
boolean |
isAuthenticated()
This method returns true if the user is authenticated to the facebook service.
|
void |
killCurrentRequest()
Kills the current request.
|
static void |
logOut()
log out the current user
|
void |
postComment(String postId,
String message)
Post a comment on a given post
|
void |
postComment(String postId,
String message,
ActionListener callback)
Post a comment on a given post
|
void |
postLike(String postId)
Post like on a given post
|
void |
postLike(String postId,
ActionListener callback)
Post like on a given post
|
void |
postOnWall(String userId,
String message)
Post a message on the users wall
|
void |
postOnWall(String userId,
String message,
ActionListener callback)
Post a message on the users wall
|
void |
postOnWall(String userId,
String message,
String name,
String link,
String description,
String picture,
String caption,
ActionListener callback)
Post a message on the users wall
|
void |
removeResponseCodeListener(ActionListener a)
Removes a response listener
|
void |
search(String objectType,
String query,
DefaultListModel results,
ActionListener callback)
Serach for facebook objects
|
static void |
setApiVersion(String apiVersion)
Sets the Facebook api version being used, by default the api calls the
non version-ed version of the API.
|
static void |
setClientId(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 void |
setClientSecret(String clientSecret)
The client secret is been generated by facebook
see: https://developers.facebook.com/apps
|
static void |
setPermissions(String[] permissions)
The requested permissions of the app
http://developers.facebook.com/docs/reference/api/permissions/
|
void |
setProgress(Slider slider)
Sets the progress indicator to get network updates on the queries
|
static void |
setRedirectURI(String redirectURI)
This is generated when an app is created see:
https://developers.facebook.com/apps
|
static void |
setToken(String tok)
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()
|
void |
showAuthentication(ActionListener al)
This method shows an authentication for login form
|
public static FaceBookAccess getInstance()
public Oauth2 createOAuth()
public Component createAuthComponent(ActionListener al)
al
- a listener that will receive at its source either a token for the service or an exception in case of a failurepublic void showAuthentication(ActionListener al)
al
- a listener that will receive at its source either a token for
the service or an exception in case of a failurepublic boolean isAuthenticated()
public void setProgress(Slider slider)
slider
- public void getFaceBookObject(String faceBookId, ActionListener callback) throws IOException
faceBookId
- the object id that we would like to querycallback
- the callback that should be updated when the data arrivesIOException
public void getFaceBookObject(String faceBookId, ActionListener callback, boolean needToken, boolean async) throws IOException
faceBookId
- the object id that we would like to querycallback
- the callback that should be updated when the data arrivesneedToken
- if true authentication is being checkedIOException
public void getFaceBookObjectItems(String faceBookId, String itemsConnection, DefaultListModel feed, Hashtable params, ActionListener callback) throws IOException
faceBookId
- the id to preform the query uponitemsConnection
- the type of the queryfeed
- params
- callback
- the callback that should be updated when the data arrivesIOException
public void getUser(String userId, User user, ActionListener callback) throws IOException
userId
- the user id or null to get detaild on the authenticated useruser
- an object to fill with the user detailscallback
- the callback that should be updated when the data arrivesIOException
public User getUser(String userId) throws IOException
userId
- the user id or null to get details on the authenticated userIOException
public Page getPage(String pageId) throws IOException
pageId
- the pageIdIOException
public void getPost(String postId, Post post, ActionListener callback) throws IOException
postId
- the postIdpost
- an Object to fill with the datacallback
- the callback that should be updated when the data arrivesIOException
public Post getPost(String postId, boolean needAuth) throws IOException
postId
- the post idneedAuth
- if this object is public needAuth can be false and no
authentication will be performedIOException
public void getPhoto(String photoId, Photo photo, ActionListener callback) throws IOException
photoId
- the photoIdphoto
- an Object to fill with the datacallback
- the callback that should be updated when the data arrivesIOException
public Photo getPhoto(String photoId, boolean needAuth) throws IOException
the
- photoIdneedAuth
- if this object is public needAuth can be false and no
authentication will be performedIOException
public void getAlbum(String albumId, Album album, ActionListener callback) throws IOException
albumId
- the albumIdalbum
- an Object to fill with the datacallback
- the callback that should be updated when the data arrivesIOException
public Album getAlbum(String albumId, boolean needAuth) throws IOException
the
- albumIdneedAuth
- if this object is public needAuth can be false and no
authentication will be performedIOException
public void getNewsFeed(String userId, DefaultListModel feed, ActionListener callback) throws IOException
userId
- the userid we would like to queryfeed
- the response to fillcallback
- the callback that should be updated when the data arrivesIOException
public void getNewsFeed(String userId, DefaultListModel feed, int limit, ActionListener callback) throws IOException
userId
- the userid we would like to queryfeed
- the response to filllimit
- the number of items to returncallback
- the callback that should be updated when the data arrivesIOException
public void getWallFeed(String userId, DefaultListModel feed, ActionListener callback) throws IOException
userId
- the userid we would like to queryfeed
- the response fo fillcallback
- the callback that should be updated when the data arrivesIOException
public void getWallFeed(String userId, DefaultListModel feed, int limit, ActionListener callback) throws IOException
userId
- the userid we would like to queryfeed
- the response to filllimit
- the number of items to returncallback
- the callback that should be updated when the data arrivesIOException
public void getWallPosts(String userId, DefaultListModel feed, ActionListener callback) throws IOException
userId
- the userid we would like to queryfeed
- the response fo fillcallback
- the callback that should be updated when the data arrivesIOException
public void getWallPosts(String userId, DefaultListModel feed, int limit, ActionListener callback) throws IOException
userId
- the userid we would like to queryfeed
- the response to filllimit
- the number of items to returncallback
- the callback that should be updated when the data arrivesIOException
public void getPicture(String id, Label label, Dimension toScale, boolean tempStorage) throws IOException
id
- the object id to querylabel
- place the image on the given label as an icontoScale
- scale the image to the given dimensiontempStorage
- if true place the image in a temp storageIOException
public void getPicture(String id, ActionListener callback, Dimension toScale, boolean tempStorage) throws IOException
id
- the object id to querycallback
- the callback that should be updated when the data arrivestoScale
- picture dimension or nulltempStorage
- if true place the image in a temp storageIOException
public EncodedImage getPictureAndWait(String id, Dimension toScale)
id
- the object id to querytoScale
- picture dimension or nullpublic String getImageURL(String id, Dimension toScale)
id
- the id of the imagetoScale
- the resolution we wantpublic void getPicture(String id, Component targetList, int targetOffset, String targetKey, Dimension toScale, boolean tempStorage) throws IOException
id
- the object id to querytargetList
- the list that should be updated when the data arrivestargetOffset
- the offset within the list to insert the imagetargetKey
- the key for the hashtable in the target offsettoScale
- the scale of the image to put in the List or nulltempStorage
- if true place the image in a temp storageIOException
public void getPhotoThumbnail(String photoId, ActionListener callback, boolean tempStorage) throws IOException
photoId
- the photo idcallback
- the callback that should be updated when the data arrivestempStorage
- if true place the image in a temp storageIOException
public void getPhotoThumbnail(String photoId, Label label, Dimension toScale, boolean tempStorage) throws IOException
photoId
- the photo idlabel
- place the image on the given label as an icontoScale
- scale the image to the given dimensiontempStorage
- if true place the image in a temp storageIOException
public void getUserFriends(String userId, DefaultListModel friends, ActionListener callback) throws IOException
userId
- the idfriends
- store friends results into the given model,
each entry is an Hashtable Object contaning the Object datacallback
- the callback that should be updated when the data arrivesIOException
public void getUserAlbums(String userId, DefaultListModel albums, ActionListener callback) throws IOException
userId
- the idalbums
- store albums results into the given model,
each entry is an Hashtable Object contaning the Object datacallback
- the callback that should be updated when the data arrivesIOException
public void getAlbumPhotos(String albumId, DefaultListModel photos, int offset, int limit, ActionListener callback) throws IOException
albumId
- the idphotos
- store photos results into the given model,
each entry is an Hashtable Object contaning the Object dataoffset
- the offset of the photo in the albumlimit
- amount of photos to bringcallback
- the callback that should be updated when the data arrivesIOException
public void getPostComments(String postId, DefaultListModel comments, ActionListener callback) throws IOException
postId
- the idcomments
- store comments results into the given model,
each entry is an Hashtable Object contaning the Object datacallback
- the callback that should be updated when the data arrivesIOException
public void getUserInboxThreads(String userId, DefaultListModel threads, int limit, ActionListener callback) throws IOException
userId
- the idthreads
- store threads results into the given model,
each entry is an Hashtable Object contaning the Object datalimit
- the amount of thread to returncallback
- the callback that should be updated when the data arrivesIOException
public void postOnWall(String userId, String message) throws IOException
userId
- the userIdmessage
- the message to postIOException
public void postLike(String postId) throws IOException
postId
- the post IdIOException
public void postComment(String postId, String message) throws IOException
postId
- the post idmessage
- the message to postIOException
public void createNote(String userId, String subject, String message) throws IOException
userId
- the userIdmessage
- the message to postIOException
public void postOnWall(String userId, String message, ActionListener callback) throws IOException
userId
- the userIdmessage
- the message to postIOException
public void postOnWall(String userId, String message, String name, String link, String description, String picture, String caption, ActionListener callback) throws IOException
userId
- the userIdmessage
- the message to postname
- link
- description
- picture
- caption
- IOException
public void postLike(String postId, ActionListener callback) throws IOException
postId
- the post IdIOException
public void postComment(String postId, String message, ActionListener callback) throws IOException
postId
- the post idmessage
- the message to postIOException
public void createNote(String userId, String subject, String message, ActionListener callback) throws IOException
userId
- the userIdmessage
- the message to postIOException
public void getUserNotifications(String userId, String startTime, boolean includeRead, DefaultListModel notifications, ActionListener callback) throws IOException
userId
- the user idstartTime
- 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
- Indicates whether to include notifications that have already been read.
By default, notifications a user has read are not included.notifications
- store notifications results into the given model,
each entry is an Hashtable Object contaning the Object datacallback
- the callback that should be updated when the data arrivesIOException
public void getUsersDetails(String[] usersIds, String[] fields, ActionListener callback) throws IOException
usersIds
- the users to queryfields
- which fields to query on the users see http://developers.facebook.com/docs/reference/rest/users.getInfo/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);
}IOException
public void getUserEvents(String userId, DefaultListModel events, ActionListener callback) throws IOException
userId
- the user idevents
- store events results into the given model,
each entry is an Hashtable Object contaning the Object datacallback
- the callback that should be updated when the data arrivesIOException
public void search(String objectType, String query, DefaultListModel results, ActionListener callback) throws IOException
objectType
- one of each: post, user, page, event, group, place, checkinquery
- the query string to search forresults
- store results onto the given model,
each entry is an Hashtable Object contaning the Object datacallback
- the callback that should be updated when the data arrivesIOException
public void killCurrentRequest()
public void addResponseCodeListener(ActionListener a)
a
- response listenerpublic void removeResponseCodeListener(ActionListener a)
public static DefaultListModel createObjectsModel(DefaultListModel hashtablesModel, Class fbObjectClass) throws IllegalAccessException, InstantiationException
hashtablesModel
- the model to transform, this model should hold it's data has Hashtable entriesfbObjectClass
- this is the class of the entries to be created, this class should be a FBObject typeIllegalAccessException
- if the fbObjectClass.newInstance() failsInstantiationExceptionif
- the fbObjectClass.newInstance() failsInstantiationException
public void cleanTempStorage()
public static void setClientId(String clientId)
clientId
- public static void setClientSecret(String clientSecret)
clientSecret
- public static void setPermissions(String[] permissions)
permissions
- public static void setRedirectURI(String redirectURI)
redirectURI
- public static void setToken(String tok)
tok
- the token of thepublic static String getToken()
public static void logOut()
public static void anonymousLogin(String appid, String clientSecret)
appid
- the id of the applicationclientSecret
- the client secret for the applicationpublic static String getApiVersion()
public static void setApiVersion(String apiVersion)
apiVersion
- valid values are "1.0", "2.0", "2.1"