com.google.code.facebookapi
Class FacebookXmlRestClient

java.lang.Object
  extended by com.google.code.facebookapi.ExtensibleClient<org.w3c.dom.Document>
      extended by com.google.code.facebookapi.FacebookXmlRestClient
All Implemented Interfaces:
IFacebookRestClient<org.w3c.dom.Document>

public class FacebookXmlRestClient
extends ExtensibleClient<org.w3c.dom.Document>

A FacebookRestClient that uses the XML result format. This means results from calls to the Facebook API are returned as XML and transformed into instances of Document.


Field Summary
protected  org.w3c.dom.Document cacheFriendsList
           
protected static org.apache.commons.logging.Log log
           
protected  boolean namespaceAware
           
 
Fields inherited from class com.google.code.facebookapi.ExtensibleClient
_apiKey, _isDesktop, _readTimeout, _secret, _serverUrl, _timeout, BATCH_LIMIT, batchMode, cacheAppAdded, cacheAppUser, cacheSessionExpires, cacheSessionKey, cacheSessionSecret, cacheUserId, CRLF, HTTPS_SERVER_URL, JAXB_CONTEXT, MARKETPLACE_STATUS_DEFAULT, MARKETPLACE_STATUS_NOT_SUCCESS, MARKETPLACE_STATUS_SUCCESS, permissionsApiKey, PREF, queries, rawResponse, SERVER_URL, UPLOAD_BUFFER_SIZE
 
Fields inherited from interface com.google.code.facebookapi.IFacebookRestClient
ERROR_TAG, FB_SERVER, HTTPS_SERVER_ADDR, SERVER_ADDR, TARGET_API_VERSION
 
Constructor Summary
FacebookXmlRestClient(java.lang.String apiKey, java.lang.String secret)
           
FacebookXmlRestClient(java.lang.String apiKey, java.lang.String secret, int connectionTimeout)
           
FacebookXmlRestClient(java.lang.String apiKey, java.lang.String secret, java.lang.String sessionKey)
           
FacebookXmlRestClient(java.lang.String apiKey, java.lang.String secret, java.lang.String sessionKey, int connectionTimeout)
           
FacebookXmlRestClient(java.lang.String serverAddr, java.lang.String apiKey, java.lang.String secret, java.lang.String sessionKey)
           
FacebookXmlRestClient(java.lang.String serverAddr, java.lang.String apiKey, java.lang.String secret, java.lang.String sessionKey, int connectionTimeout)
           
FacebookXmlRestClient(java.net.URL serverUrl, java.lang.String apiKey, java.lang.String secret, java.lang.String sessionKey)
           
FacebookXmlRestClient(java.net.URL serverUrl, java.lang.String apiKey, java.lang.String secret, java.lang.String sessionKey, int connectionTimeout)
           
FacebookXmlRestClient(java.net.URL serverUrl, java.lang.String apiKey, java.lang.String secret, java.lang.String sessionKey, int connectionTimeout, int readTimeout)
           
 
Method Summary
 java.lang.String admin_getAppPropertiesAsString(java.util.Collection<ApplicationProperty> properties)
          Retrieve application properties.
 java.lang.String auth_getSession(java.lang.String authToken)
          Call this function to retrieve the session information after your user has logged in.
 java.util.List<? extends java.lang.Object> executeBatch(boolean serial)
          Executes a batch of queries.
protected  int extractInt(org.w3c.dom.Document doc)
          Extracts an Integer from a document that consists of an Integer only.
protected  java.lang.Long extractLong(org.w3c.dom.Document doc)
          Extracts a Long from a document that consists of a Long only.
static java.lang.String extractNodeString(org.w3c.dom.Node d)
           
 java.lang.String extractString(org.w3c.dom.Document d)
          Extracts a String from a T consisting entirely of a String.
protected  java.net.URL extractURL(org.w3c.dom.Document doc)
          Extracts a URL from a document that consists of a URL only.
 org.w3c.dom.Document friends_get()
          Retrieves the friends of the currently logged in user.
 org.w3c.dom.Document getCacheFriendsList()
          Return the object's 'friendsList' property.
 java.lang.String getResponseFormat()
          The response format in which results to FacebookMethod calls are returned
 boolean isNamespaceAware()
           
 java.util.List<Listing> marketplace_getListings(java.util.List<java.lang.Long> listingIds, java.util.List<java.lang.Long> uids)
          Retrieve listings from the marketplace.
 java.util.List<java.lang.String> marketplace_getSubCategories()
          Return a list of all valid Marketplace subcategories.
 java.util.List<Listing> marketplace_search(MarketListingCategory category, MarketListingSubcategory subcategory, java.lang.String searchTerm)
          Search the marketplace listings by category, subcategory, and keyword.
protected  org.w3c.dom.Document parseCallResult(java.io.InputStream data, IFacebookMethod method)
          Parses the result of an API call into a T.
 void printDom(org.w3c.dom.Node n, java.lang.String prefix)
          Prints out the DOM tree.
 void setCacheFriendsList(java.util.List<java.lang.Long> ids)
          Set/override the list of friends stored in the client.
 void setNamespaceAware(boolean v)
           
static org.w3c.dom.Document toFriendsGetResponse(java.util.List<java.lang.Long> ids)
           
 
Methods inherited from class com.google.code.facebookapi.ExtensibleClient
addParam, addParam, addParam, addParamDelimitIfNotBlankEmpty, addParamIfNotBlank, addParamIfNotBlank, addParamIfNotBlankZero, addParamSecondsIfNotBlank, admin_getAllocation, admin_getAllocation, admin_getAppProperties, admin_getAppPropertiesAsSet, admin_getAppPropertiesMap, admin_getDailyMetrics, admin_getDailyMetrics, admin_getMetrics, admin_getMetrics, admin_getNotificationAllocation, admin_getRequestAllocation, admin_setAppProperties, admin_setAppProperties, application_getPublicInfo, application_getPublicInfoByApiKey, application_getPublicInfoByCanvasName, application_getPublicInfoById, auth_createToken, auth_expireSession, auth_getUserId, auth_promoteSession, auth_revokeAuthorization, batch_run, beginBatch, beginPermissionsMode, callMethod, callMethod, callMethod, close, connect_getUnconnectedFriendsCount, connect_registerUsers, connect_unregisterUsers, data_createObject, data_createObjectType, data_defineAssociation, data_defineObjectProperty, data_deleteObject, data_deleteObjects, data_dropObjectType, data_getAssociatedObjectCount, data_getAssociationDefinition, data_getAssociationDefinitions, data_getCookies, data_getCookies, data_getCookies, data_getCookies, data_getObject, data_getObjectProperty, data_getObjects, data_getObjectType, data_getObjectTypes, data_getUserPreference, data_getUserPreferences, data_removeAssociatedObjects, data_removeAssociation, data_renameAssociation, data_renameObjectProperty, data_renameObjectType, data_setAssociation, data_setCookie, data_setCookie, data_setCookie, data_setCookie, data_setCookie, data_setCookie, data_setCookie, data_setCookie, data_setObjectProperty, data_setUserPreference, data_setUserPreferences, data_undefineAssociation, data_undefineObjectProperty, data_updateObject, delimit, disconnect, encodeMethods, endPermissionsMode, events_cancel, events_create, events_edit, events_get, events_get, events_getMembers, events_rsvp, extractBoolean, fbml_refreshImgSrc, fbml_refreshImgSrc, fbml_refreshRefUrl, fbml_refreshRefUrl, fbml_setRefHandle, feed_deactivateTemplateBundleByID, feed_getRegisteredTemplateBundleByID, feed_getRegisteredTemplateBundles, feed_publishTemplatizedAction, feed_publishTemplatizedAction, feed_publishTemplatizedAction, feed_publishTemplatizedAction, feed_publishTemplatizedAction, feed_publishTemplatizedAction, feed_publishTemplatizedAction, feed_PublishTemplatizedAction, feed_publishUserAction, feed_publishUserAction, feed_publishUserAction, feed_registerTemplateBundle, feed_registerTemplateBundle, feed_registerTemplateBundle, feed_registerTemplateBundle, feed_registerTemplateBundle, fql_query, friends_areFriends, friends_areFriends, friends_get, friends_getAppUsers, friends_getList, friends_getLists, getCacheAppAdded, getCacheAppUser, getCacheSessionExpires, getCacheSessionKey, getCacheSessionSecret, getCacheUserId, getDefaultServerUrl, getJaxbContext, getRawResponse, getResponsePOJO, getSessionSecret, groups_get, groups_getMembers, handleFeedImages, initJaxbSupport, isDesktop, liveMessage_send, marketplace_createListing, marketplace_createListing, marketplace_createListing, marketplace_createListing, marketplace_createListing, marketplace_createListing, marketplace_createListing, marketplace_editListing, marketplace_editListing, marketplace_getCategories, marketplace_getCategoriesObject, marketplace_getListings, marketplace_getSubCategories, marketplace_removeListing, marketplace_removeListing, marketplace_removeListing, marketplace_removeListing, marketplace_removeListing, marketplace_search, newPair, newPair, newPair, newPair, newPair, newPair10, newPairTF, notifications_get, notifications_send, notifications_send, notifications_send, notifications_send, notifications_sendEmail, notifications_sendEmail, notifications_sendEmailPlain, notifications_sendEmailStr, notifications_sendEmailToCurrentUser, notifications_sendFbmlEmail, notifications_sendFbmlEmailToCurrentUser, notifications_sendTextEmail, notifications_sendTextEmailToCurrentUser, pages_getInfo, pages_getInfo, pages_getInfo, pages_getInfo, pages_isAdmin, pages_isAppAdded, pages_isFan, pages_isFan, permissions_checkAvailableApiAccess, permissions_checkGrantedApiAccess, permissions_grantApiAccess, permissions_grantFullApiAccess, permissions_revokeApiAccess, photos_addTag, photos_addTag, photos_addTag, photos_addTag, photos_addTags, photos_addTags, photos_createAlbum, photos_createAlbum, photos_createAlbum, photos_createAlbum, photos_get, photos_get, photos_get, photos_get, photos_get, photos_getAlbums, photos_getAlbums, photos_getAlbums, photos_getByAlbum, photos_getByAlbum, photos_getTags, photos_upload, photos_upload, photos_upload, photos_upload, photos_upload, photos_upload, photos_upload, photos_upload, photos_upload, postFileRequest, printDom, profile_getFBML, profile_getFBML, profile_getFBML, profile_getFBML, profile_getInfo, profile_getInfoOptions, profile_setFBML, profile_setFBML, profile_setFBML, profile_setFBML, profile_setFBML, profile_setFBML, profile_setInfo, profile_setInfoOptions, profile_setMobileFBML, profile_setMobileFBML, profile_setProfileActionFBML, profile_setProfileActionFBML, profile_setProfileFBML, profile_setProfileFBML, runtimeException, setCacheAppAdded, setCacheAppUser, setCacheSession, setCacheSessionExpires, setCacheSessionKey, setCacheSessionSecret, setCacheUserId, setDefaultServerUrl, setIsDesktop, setJaxbContext, setServerUrl, setSessionSecret, sms_canSend, sms_canSend, sms_send, sms_send, sms_sendMessage, sms_sendMessageWithSession, templatizedFeedHandler, toJson, toJsonListOfMaps, toJsonListOfStrings, toString, users_clearStatus, users_getInfo, users_getInfo, users_getLoggedInUser, users_getStandardInfo, users_getStandardInfo, users_hasAppPermission, users_hasAppPermission, users_isAppAdded, users_isAppAdded, users_isAppUser, users_isAppUser, users_setStatus, users_setStatus, users_setStatus, users_setStatus, users_setStatus, users_setStatus
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

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

namespaceAware

protected boolean namespaceAware

cacheFriendsList

protected org.w3c.dom.Document cacheFriendsList
Constructor Detail

FacebookXmlRestClient

public FacebookXmlRestClient(java.lang.String apiKey,
                             java.lang.String secret)

FacebookXmlRestClient

public FacebookXmlRestClient(java.lang.String apiKey,
                             java.lang.String secret,
                             int connectionTimeout)

FacebookXmlRestClient

public FacebookXmlRestClient(java.lang.String apiKey,
                             java.lang.String secret,
                             java.lang.String sessionKey)

FacebookXmlRestClient

public FacebookXmlRestClient(java.lang.String apiKey,
                             java.lang.String secret,
                             java.lang.String sessionKey,
                             int connectionTimeout)

FacebookXmlRestClient

public FacebookXmlRestClient(java.lang.String serverAddr,
                             java.lang.String apiKey,
                             java.lang.String secret,
                             java.lang.String sessionKey)
                      throws java.net.MalformedURLException
Throws:
java.net.MalformedURLException

FacebookXmlRestClient

public FacebookXmlRestClient(java.lang.String serverAddr,
                             java.lang.String apiKey,
                             java.lang.String secret,
                             java.lang.String sessionKey,
                             int connectionTimeout)
                      throws java.net.MalformedURLException
Throws:
java.net.MalformedURLException

FacebookXmlRestClient

public FacebookXmlRestClient(java.net.URL serverUrl,
                             java.lang.String apiKey,
                             java.lang.String secret,
                             java.lang.String sessionKey)

FacebookXmlRestClient

public FacebookXmlRestClient(java.net.URL serverUrl,
                             java.lang.String apiKey,
                             java.lang.String secret,
                             java.lang.String sessionKey,
                             int connectionTimeout)

FacebookXmlRestClient

public FacebookXmlRestClient(java.net.URL serverUrl,
                             java.lang.String apiKey,
                             java.lang.String secret,
                             java.lang.String sessionKey,
                             int connectionTimeout,
                             int readTimeout)
Method Detail

isNamespaceAware

public boolean isNamespaceAware()

setNamespaceAware

public void setNamespaceAware(boolean v)

getResponseFormat

public java.lang.String getResponseFormat()
The response format in which results to FacebookMethod calls are returned

Specified by:
getResponseFormat in class ExtensibleClient<org.w3c.dom.Document>
Returns:
the format: either XML, JSON, or null (API default)

extractString

public java.lang.String extractString(org.w3c.dom.Document d)
Extracts a String from a T consisting entirely of a String.

Specified by:
extractString in class ExtensibleClient<org.w3c.dom.Document>
Returns:
the String

auth_getSession

public java.lang.String auth_getSession(java.lang.String authToken)
                                 throws FacebookException
Call this function to retrieve the session information after your user has logged in.

Specified by:
auth_getSession in interface IFacebookRestClient<org.w3c.dom.Document>
Specified by:
auth_getSession in class ExtensibleClient<org.w3c.dom.Document>
Parameters:
authToken - the token returned by auth_createToken or passed back to your callback_url.
Throws:
FacebookException
See Also:
http://wiki.developers.facebook.com/index.php/Auth.getSession

parseCallResult

protected org.w3c.dom.Document parseCallResult(java.io.InputStream data,
                                               IFacebookMethod method)
                                        throws FacebookException,
                                               java.io.IOException
Description copied from class: ExtensibleClient
Parses the result of an API call into a T.

Specified by:
parseCallResult in class ExtensibleClient<org.w3c.dom.Document>
Parameters:
data - an InputStream with the results of a request to the Facebook servers
method - the method called
Returns:
a T
Throws:
FacebookException - if data represents an error
java.io.IOException - if data is not readable

extractURL

protected java.net.URL extractURL(org.w3c.dom.Document doc)
                           throws java.io.IOException
Extracts a URL from a document that consists of a URL only.

Specified by:
extractURL in class ExtensibleClient<org.w3c.dom.Document>
Parameters:
doc -
Returns:
the URL
Throws:
java.io.IOException

extractInt

protected int extractInt(org.w3c.dom.Document doc)
Extracts an Integer from a document that consists of an Integer only.

Specified by:
extractInt in class ExtensibleClient<org.w3c.dom.Document>
Parameters:
doc -
Returns:
the Integer

extractLong

protected java.lang.Long extractLong(org.w3c.dom.Document doc)
Extracts a Long from a document that consists of a Long only.

Specified by:
extractLong in class ExtensibleClient<org.w3c.dom.Document>
Parameters:
doc -
Returns:
the Long

printDom

public void printDom(org.w3c.dom.Node n,
                     java.lang.String prefix)
Prints out the DOM tree.


marketplace_getListings

public java.util.List<Listing> marketplace_getListings(java.util.List<java.lang.Long> listingIds,
                                                       java.util.List<java.lang.Long> uids)
                                                throws FacebookException
Description copied from interface: IFacebookRestClient
Retrieve listings from the marketplace. The listings can be filtered by listing-id or user-id (or both).

Parameters:
listingIds - the ids of listings to filter by, only listings matching the specified ids will be returned.
uids - the ids of users to filter by, only listings submitted by those users will be returned.
Returns:
A list of marketplace listings that meet the specified filter criteria.
Throws:
FacebookException - if an error happens when executing the API call.

marketplace_getSubCategories

public java.util.List<java.lang.String> marketplace_getSubCategories()
                                                              throws FacebookException
Description copied from interface: IFacebookRestClient
Return a list of all valid Marketplace subcategories.

Returns:
a list of marketplace subcategories allowed by Facebook.
Throws:
FacebookException - if an error happens when executing the API call.

marketplace_search

public java.util.List<Listing> marketplace_search(MarketListingCategory category,
                                                  MarketListingSubcategory subcategory,
                                                  java.lang.String searchTerm)
                                           throws FacebookException
Description copied from interface: IFacebookRestClient
Search the marketplace listings by category, subcategory, and keyword.

Parameters:
category - the category to search in, optional (unless subcategory is specified).
subcategory - the subcategory to search in, optional.
searchTerm - the keyword to search for, optional.
Returns:
a list of marketplace entries that match the specified search parameters.
Throws:
FacebookException - if an error happens when executing the API call.

admin_getAppPropertiesAsString

public java.lang.String admin_getAppPropertiesAsString(java.util.Collection<ApplicationProperty> properties)
                                                throws FacebookException
Description copied from interface: IFacebookRestClient
Retrieve application properties. The properties are used by Facebook to describe the configuration of your application. This method cannot be called by desktop apps.

Parameters:
properties - a collection indicating the properties you are interested in retrieving.
Returns:
a JSON-encoded string containing the properties. It is your responsibility to parse the string. Details can be found at http://wiki.developers.facebook.com/index.php/Admin.getAppProperties
Throws:
FacebookException

executeBatch

public java.util.List<? extends java.lang.Object> executeBatch(boolean serial)
                                                        throws FacebookException
Executes a batch of queries. You define the queries to execute by calling 'beginBatch' and then invoking the desired API methods that you want to execute as part of your batch as normal. Invoking this method will then execute the API calls you made in the interim as a single batch query.

Parameters:
serial - set to true, and your batch queries will always execute serially, in the same order in which your specified them. If set to false, the Facebook API server may execute your queries in parallel and/or out of order in order to improve performance.
Returns:
a list containing the results of the batch execution. The list will be ordered such that the first element corresponds to the result of the first query in the batch, and the second element corresponds to the result of the second query, and so on. The types of the objects in the list will match the type normally returned by the API call being invoked (so calling users_getLoggedInUser as part of a batch will place a Long in the list, and calling friends_get will place a Document in the list, etc.). The list may be empty, it will never be null.
Throws:
FacebookException
java.io.IOException

extractNodeString

public static java.lang.String extractNodeString(org.w3c.dom.Node d)

getCacheFriendsList

public org.w3c.dom.Document getCacheFriendsList()
Return the object's 'friendsList' property. This method does not call the Facebook API server.

Returns:
the friends-list stored in the API client.

setCacheFriendsList

public void setCacheFriendsList(java.util.List<java.lang.Long> ids)
Set/override the list of friends stored in the client.

Parameters:
friendsList - the new list to use.

toFriendsGetResponse

public static org.w3c.dom.Document toFriendsGetResponse(java.util.List<java.lang.Long> ids)

friends_get

public org.w3c.dom.Document friends_get()
                                 throws FacebookException
Description copied from interface: IFacebookRestClient
Retrieves the friends of the currently logged in user.

Specified by:
friends_get in interface IFacebookRestClient<org.w3c.dom.Document>
Overrides:
friends_get in class ExtensibleClient<org.w3c.dom.Document>
Throws:
FacebookException
See Also:
http://wiki.developers.facebook.com/index.php/Friends.get


Copyright © 2008. All Rights Reserved.