net.sf.fb4j
Class FacebookSession

java.lang.Object
  extended by net.sf.fb4j.FacebookSession

public class FacebookSession
extends java.lang.Object

Main entry point and common interface to Facebook REST interface functionality. Encapsulates and requires a Facebook session key, thus all functionality here is accessible to logged-in users only. This class is generally not instantiated directly. Depending on the type of application, an instance may be obtained as follows: TODO G: doc: CanvasRequest.getSession, DesktopApplication.createSession, etc. TODO G: method to check if session is expired?

Author:
Gino Miceli, Mino Togna

Constructor Summary
FacebookSession(java.lang.String apiKey, java.lang.String secretKey, java.lang.String sessionKey)
           
FacebookSession(java.lang.String apiKey, java.lang.String secretKey, java.lang.String sessionKey, long loggedInUserId)
           
 
Method Summary
 boolean addPhotoTags(PhotoTag... photoTags)
           
 boolean clearStatus()
           
 long createMarketplaceListing(Listing listing, boolean showOnProfile)
          facebook.marketplace.createListing
 PhotoAlbum createPhotoAlbum(PhotoAlbum album)
           
 FacebookObject<? extends java.lang.Enum<? extends FacebookField>>[] executeQuery(java.lang.String fql)
           
 Listing[] findMarketplaceListings(java.lang.String category, java.lang.String subcategory, java.lang.String queryString)
           
 long[] getAppUserFriendIds()
           
 Event getEvent(long eventId)
           
 EventMembersByStatus getEventMembers(long eventId)
           
 Event[] getEvents()
           
 Event[] getEvents(long... eventIds)
           
 Event[] getEvents(long userId, long[] eventIds, long startTime, long endTime, EventMembersByStatus.RsvpStatus rsvpStatus)
           
 long[] getFriendIds()
           
 Group getGroup(long groupId)
           
 GroupMembersByRole getGroupMembers(long groupId)
           
 Group[] getGroups(long userId, long... groupIds)
           
 java.lang.String[] getMarketplaceCategories()
           
 Listing getMarketplaceListing(long listingId)
           
 Listing[] getMarketplaceListings(long... listingIds)
           
 Listing[] getMarketplaceListings(long[] listingIds, long[] userIds)
           
 Listing[] getMarketplaceListingsByUser()
           
 Listing[] getMarketplaceListingsByUsers(long... userIds)
           
 java.lang.String[] getMarketplaceSubcategories(java.lang.String category)
           
 OutstandingNotifications getOutstandingNotifications()
          notifications.get
 Page[] getPageInfo(long[] pageIds, long userId, java.lang.String type, Page.Field... fields)
           
 Page[] getPageInfo(long[] pageIds, Page.Field... fields)
           
 Page getPageInfo(long pageId, Page.Field... fields)
           
 Page[] getPageInfo(Page.Field... fields)
           
 PhotoAlbum getPhotoAlbum(long albumId)
           
 PhotoAlbum[] getPhotoAlbums(long... albumIds)
           
 PhotoAlbum[] getPhotoAlbums(long userId, long[] albumIds)
           
 PhotoAlbum[] getPhotoAlbumsByUser()
           
 PhotoAlbum[] getPhotoAlbumsByUser(long userId)
           
 Photo getPhotoById(long photoId)
           
 Photo[] getPhotos(long subjectId, long albumId, long... photoIds)
           
 Photo[] getPhotosByAlbum(long albumId)
           
 Photo[] getPhotosById(long... photoIds)
           
 Photo[] getPhotosOfUser()
           
 Photo[] getPhotosOfUser(long userId)
           
 PhotoTag[] getPhotoTags(long... photoIds)
           
 java.lang.String getProfileFbml()
           
 java.lang.String getProfileFbml(long userId)
           
 Relationship[] getRelationship(long[] userIds1, long[] userIds2)
           
 java.lang.String getSessionKey()
           
 java.lang.String getStatus()
           
 java.lang.String getStatus(long userId)
           
 long getUserId()
          Caches logged in user ID if it is already known
 UserInfo[] getUserInfo(long[] userIds, UserInfo.Field... fields)
           
 UserInfo getUserInfo(long userId, UserInfo.Field... fields)
           
 UserInfo getUserInfo(UserInfo.Field... fields)
           
 boolean hasAppPermission(ExtendedPermission extendedPermission)
          Checks if the user granted the app permission to...
 boolean isAppAdded()
          Checks whether the user has added the application to their Facebook account
 boolean isAppAddedToPage()
           
 boolean isAppAddedToPage(long pageId)
           
 boolean isPageAdmin(long pageId)
           
 boolean isPageFan(long pageId)
           
 boolean isPageFan(long pageId, long userId)
           
 boolean publishAction(FeedStory story)
           
 boolean publishAction(FeedStoryTemplate template)
           
 boolean publishStory(FeedStory story)
           
 boolean refreshImgSrc(java.lang.String url)
           
 boolean refreshRefUrl(java.lang.String url)
           
 boolean removeMarketplaceListing(long listingId, java.lang.String status)
          facebook.marketplace.removeListing
 long[] sendEmail(FacebookEmail facebookEmail)
           
 void sendNotification(java.lang.String notification, long... toUserIds)
           
 boolean setProfileFbml(long userId, java.lang.String fbml)
           
 boolean setProfileFbml(java.lang.String fbml)
           
 boolean setRefHandle(java.lang.String handle, java.lang.String fbml)
           
 void setSessionTimeout(int timeout)
           
 boolean setStatus(java.lang.String status)
           
 long updateMarketplaceListing(Listing listing, boolean showOnProfile)
          facebook.marketplace.createListing
 Photo uploadPhoto(long albumId, java.lang.String caption, java.io.File file)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FacebookSession

public FacebookSession(java.lang.String apiKey,
                       java.lang.String secretKey,
                       java.lang.String sessionKey)

FacebookSession

public FacebookSession(java.lang.String apiKey,
                       java.lang.String secretKey,
                       java.lang.String sessionKey,
                       long loggedInUserId)
Method Detail

getSessionKey

public java.lang.String getSessionKey()

setSessionTimeout

public void setSessionTimeout(int timeout)

refreshImgSrc

public boolean refreshImgSrc(java.lang.String url)
                      throws FacebookClientException
Throws:
FacebookClientException

refreshRefUrl

public boolean refreshRefUrl(java.lang.String url)
                      throws FacebookClientException
Throws:
FacebookClientException

setRefHandle

public boolean setRefHandle(java.lang.String handle,
                            java.lang.String fbml)
                     throws FacebookClientException
Throws:
FacebookClientException

publishStory

public boolean publishStory(FeedStory story)
                     throws FacebookClientException
Throws:
FacebookClientException

publishAction

public boolean publishAction(FeedStory story)
                      throws FacebookClientException
Throws:
FacebookClientException

publishAction

public boolean publishAction(FeedStoryTemplate template)
                      throws FacebookClientException
Throws:
FacebookClientException

executeQuery

public FacebookObject<? extends java.lang.Enum<? extends FacebookField>>[] executeQuery(java.lang.String fql)
                                                                                 throws FacebookClientException
Throws:
FacebookClientException

getRelationship

public Relationship[] getRelationship(long[] userIds1,
                                      long[] userIds2)
                               throws FacebookClientException
Throws:
FacebookClientException

getFriendIds

public long[] getFriendIds()
                    throws FacebookClientException
Throws:
FacebookClientException

getAppUserFriendIds

public long[] getAppUserFriendIds()
                           throws FacebookClientException
Throws:
FacebookClientException

getOutstandingNotifications

public OutstandingNotifications getOutstandingNotifications()
                                                     throws FacebookClientException
notifications.get

Throws:
FacebookClientException

sendNotification

public void sendNotification(java.lang.String notification,
                             long... toUserIds)
                      throws FacebookClientException
Throws:
FacebookClientException

sendEmail

public long[] sendEmail(FacebookEmail facebookEmail)
                 throws FacebookClientException
Throws:
FacebookClientException

setProfileFbml

public boolean setProfileFbml(long userId,
                              java.lang.String fbml)
                       throws FacebookClientException
Throws:
FacebookClientException

setProfileFbml

public boolean setProfileFbml(java.lang.String fbml)
                       throws FacebookClientException
Throws:
FacebookClientException

getProfileFbml

public java.lang.String getProfileFbml(long userId)
                                throws FacebookClientException
Throws:
FacebookClientException

getProfileFbml

public java.lang.String getProfileFbml()
                                throws FacebookClientException
Throws:
FacebookClientException

getUserInfo

public UserInfo[] getUserInfo(long[] userIds,
                              UserInfo.Field... fields)
                       throws FacebookClientException
Throws:
FacebookClientException

getUserInfo

public UserInfo getUserInfo(long userId,
                            UserInfo.Field... fields)
                     throws FacebookClientException
Throws:
FacebookClientException

getUserInfo

public UserInfo getUserInfo(UserInfo.Field... fields)
                     throws FacebookClientException
Throws:
FacebookClientException

getUserId

public long getUserId()
               throws FacebookClientException
Caches logged in user ID if it is already known

Throws:
FacebookClientException

getStatus

public java.lang.String getStatus(long userId)
                           throws FacebookClientException
Throws:
FacebookClientException

getStatus

public java.lang.String getStatus()
                           throws FacebookClientException
Throws:
FacebookClientException

setStatus

public boolean setStatus(java.lang.String status)
                  throws FacebookClientException
Throws:
FacebookClientException

clearStatus

public boolean clearStatus()
                    throws FacebookClientException
Throws:
FacebookClientException

hasAppPermission

public boolean hasAppPermission(ExtendedPermission extendedPermission)
                         throws java.lang.Exception
Checks if the user granted the app permission to...

Parameters:
extPerm -
Returns:
Throws:
java.lang.Exception

isAppAdded

public boolean isAppAdded()
                   throws FacebookClientException
Checks whether the user has added the application to their Facebook account

Returns:
Throws:
FacebookClientException

getEvents

public Event[] getEvents(long userId,
                         long[] eventIds,
                         long startTime,
                         long endTime,
                         EventMembersByStatus.RsvpStatus rsvpStatus)
                  throws FacebookClientException
Throws:
FacebookClientException

getEvents

public Event[] getEvents(long... eventIds)
                  throws FacebookClientException
Throws:
FacebookClientException

getEvent

public Event getEvent(long eventId)
               throws FacebookClientException
Throws:
FacebookClientException

getEvents

public Event[] getEvents()
                  throws FacebookClientException
Throws:
FacebookClientException

getEventMembers

public EventMembersByStatus getEventMembers(long eventId)
                                     throws FacebookClientException
Throws:
FacebookClientException

getGroups

public Group[] getGroups(long userId,
                         long... groupIds)
                  throws FacebookClientException
Throws:
FacebookClientException

getGroup

public Group getGroup(long groupId)
               throws FacebookClientException
Throws:
FacebookClientException

getGroupMembers

public GroupMembersByRole getGroupMembers(long groupId)
                                   throws FacebookClientException
Throws:
FacebookClientException

addPhotoTags

public boolean addPhotoTags(PhotoTag... photoTags)
                     throws FacebookClientException
Throws:
FacebookClientException

createPhotoAlbum

public PhotoAlbum createPhotoAlbum(PhotoAlbum album)
                            throws FacebookClientException
Throws:
FacebookClientException

getPhotos

public Photo[] getPhotos(long subjectId,
                         long albumId,
                         long... photoIds)
                  throws FacebookClientException
Throws:
FacebookClientException

getPhotosById

public Photo[] getPhotosById(long... photoIds)
                      throws FacebookClientException
Throws:
FacebookClientException

getPhotoById

public Photo getPhotoById(long photoId)
                   throws FacebookClientException
Throws:
FacebookClientException

getPhotosByAlbum

public Photo[] getPhotosByAlbum(long albumId)
                         throws FacebookClientException
Throws:
FacebookClientException

getPhotosOfUser

public Photo[] getPhotosOfUser()
                        throws FacebookClientException
Throws:
FacebookClientException

getPhotosOfUser

public Photo[] getPhotosOfUser(long userId)
                        throws FacebookClientException
Throws:
FacebookClientException

getPhotoAlbums

public PhotoAlbum[] getPhotoAlbums(long userId,
                                   long[] albumIds)
                            throws FacebookClientException
Throws:
FacebookClientException

getPhotoAlbums

public PhotoAlbum[] getPhotoAlbums(long... albumIds)
                            throws FacebookClientException
Throws:
FacebookClientException

getPhotoAlbum

public PhotoAlbum getPhotoAlbum(long albumId)
                         throws FacebookClientException
Throws:
FacebookClientException

getPhotoAlbumsByUser

public PhotoAlbum[] getPhotoAlbumsByUser(long userId)
                                  throws FacebookClientException
Throws:
FacebookClientException

getPhotoAlbumsByUser

public PhotoAlbum[] getPhotoAlbumsByUser()
                                  throws FacebookClientException
Throws:
FacebookClientException

getPhotoTags

public PhotoTag[] getPhotoTags(long... photoIds)
                        throws FacebookClientException
Throws:
FacebookClientException

uploadPhoto

public Photo uploadPhoto(long albumId,
                         java.lang.String caption,
                         java.io.File file)
                  throws FacebookClientException
Throws:
FacebookClientException

getMarketplaceCategories

public java.lang.String[] getMarketplaceCategories()
                                            throws FacebookClientException
Throws:
FacebookClientException

getMarketplaceSubcategories

public java.lang.String[] getMarketplaceSubcategories(java.lang.String category)
                                               throws FacebookClientException
Throws:
FacebookClientException

getMarketplaceListingsByUser

public Listing[] getMarketplaceListingsByUser()
                                       throws FacebookClientException
Throws:
FacebookClientException

getMarketplaceListingsByUsers

public Listing[] getMarketplaceListingsByUsers(long... userIds)
                                        throws FacebookClientException
Throws:
FacebookClientException

getMarketplaceListing

public Listing getMarketplaceListing(long listingId)
                              throws FacebookClientException
Throws:
FacebookClientException

getMarketplaceListings

public Listing[] getMarketplaceListings(long... listingIds)
                                 throws FacebookClientException
Throws:
FacebookClientException

getMarketplaceListings

public Listing[] getMarketplaceListings(long[] listingIds,
                                        long[] userIds)
                                 throws FacebookClientException
Throws:
FacebookClientException

findMarketplaceListings

public Listing[] findMarketplaceListings(java.lang.String category,
                                         java.lang.String subcategory,
                                         java.lang.String queryString)
                                  throws FacebookClientException
Throws:
FacebookClientException

createMarketplaceListing

public long createMarketplaceListing(Listing listing,
                                     boolean showOnProfile)
                              throws FacebookClientException
facebook.marketplace.createListing

Throws:
FacebookClientException

updateMarketplaceListing

public long updateMarketplaceListing(Listing listing,
                                     boolean showOnProfile)
                              throws FacebookClientException
facebook.marketplace.createListing

Throws:
FacebookClientException

removeMarketplaceListing

public boolean removeMarketplaceListing(long listingId,
                                        java.lang.String status)
                                 throws FacebookClientException
facebook.marketplace.removeListing

Throws:
FacebookClientException

getPageInfo

public Page[] getPageInfo(Page.Field... fields)
                   throws FacebookClientException
Throws:
FacebookClientException

getPageInfo

public Page getPageInfo(long pageId,
                        Page.Field... fields)
                 throws FacebookClientException
Throws:
FacebookClientException

getPageInfo

public Page[] getPageInfo(long[] pageIds,
                          Page.Field... fields)
                   throws FacebookClientException
Throws:
FacebookClientException

getPageInfo

public Page[] getPageInfo(long[] pageIds,
                          long userId,
                          java.lang.String type,
                          Page.Field... fields)
                   throws FacebookClientException
Throws:
FacebookClientException

isAppAddedToPage

public boolean isAppAddedToPage()
                         throws FacebookClientException
Throws:
FacebookClientException

isAppAddedToPage

public boolean isAppAddedToPage(long pageId)
                         throws FacebookClientException
Throws:
FacebookClientException

isPageAdmin

public boolean isPageAdmin(long pageId)
                    throws FacebookClientException
Throws:
FacebookClientException

isPageFan

public boolean isPageFan(long pageId)
                  throws FacebookClientException
Throws:
FacebookClientException

isPageFan

public boolean isPageFan(long pageId,
                         long userId)
                  throws FacebookClientException
Throws:
FacebookClientException


Copyright © 2008. All Rights Reserved.