com.google.code.facebookapi
Class FacebookJaxbRestClientBase
java.lang.Object
com.google.code.facebookapi.BaseAdapter
com.google.code.facebookapi.SpecificReturnTypeAdapter<java.lang.Object>
com.google.code.facebookapi.FacebookJaxbRestClientBase
- All Implemented Interfaces:
- IFacebookRestClient<java.lang.Object>
- Direct Known Subclasses:
- FacebookJaxbRestClient
public abstract class FacebookJaxbRestClientBase
- extends SpecificReturnTypeAdapter<java.lang.Object>
A FacebookRestClient that JAXB response objects. This means results from calls to the Facebook API are returned as XML and transformed into JAXB Java objects.
|
Field Summary |
protected static javax.xml.bind.JAXBContext |
JAXB_CONTEXT
|
protected static org.apache.commons.logging.Log |
log
|
|
Method Summary |
java.util.List<? extends java.lang.Object> |
executeBatch(boolean serial)
Executes a batch of queries. |
javax.xml.bind.JAXBContext |
getJaxbContext()
|
java.lang.Object |
getResponsePOJO()
Returns a JAXB object of the type that corresponds to the last API call made on the client. |
java.lang.Object |
getResponsePOJO(java.lang.String rawResponse)
|
static void |
initJaxbSupport()
|
protected java.lang.Object |
parseCallResult(java.lang.Object rawResponse)
Parses the result of an API call from XML into JAXB Objects. |
void |
setJaxbContext(javax.xml.bind.JAXBContext context)
|
| Methods inherited from class com.google.code.facebookapi.SpecificReturnTypeAdapter |
admin_getAllocation, admin_getAllocation, admin_getAllocation, admin_getAllocation, admin_getAppProperties, admin_getAppPropertiesAsSet, admin_getAppPropertiesAsString, admin_getAppPropertiesMap, admin_getNotificationAllocation, admin_getRequestAllocation, admin_setAppProperties, admin_setAppProperties, auth_createToken, auth_expireSession, auth_getSession, auth_getSession, auth_promoteSession, auth_revokeAuthorization, auth_revokeExtendedPermission, auth_revokeExtendedPermission, connect_getUnconnectedFriendsCount, dashboard_addGlobalNews, dashboard_addGlobalNews, dashboard_clearGlobalNews, dashboard_clearGlobalNews, dashboard_multiIncrementCount, dashboard_publishActivity, dashboard_publishActivity, data_createObject, data_getAssociatedObjectCount, data_getUserPreference, data_setCookie, data_setCookie, data_setCookie, data_setCookie, data_setCookie, data_setCookie, data_setCookie, data_setCookie, events_cancel, events_create, events_edit, events_rsvp, fbml_refreshImgSrc, fbml_refreshImgSrc, fbml_refreshRefUrl, fbml_refreshRefUrl, fbml_setRefHandle, feed_deactivateTemplateBundleByID, 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, getCacheAppUser, getCacheSessionExpires, getCacheSessionKey, getCacheUserId, intl_uploadNativeStrings, isDesktop, links_post, liveMessage_send, 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_isAdmin, pages_isAppAdded, pages_isFan, pages_isFan, permissions_grantApiAccess, permissions_grantFullApiAccess, permissions_revokeApiAccess, photos_addTag, photos_addTag, photos_addTag, photos_addTag, profile_setFBML, profile_setFBML, profile_setFBML, profile_setFBML, profile_setFBML, profile_setFBML, profile_setMobileFBML, profile_setMobileFBML, profile_setProfileActionFBML, profile_setProfileActionFBML, profile_setProfileFBML, profile_setProfileFBML, sms_canSend, sms_canSend, sms_send, sms_send, sms_sendMessageWithSession, stream_addComment, stream_addLike, stream_publish, stream_remove, stream_removeComment, stream_removeLike, users_clearStatus, users_getLoggedInUser, users_hasAppPermission, users_hasAppPermission, users_isAppUser, users_isAppUser, users_setStatus, users_setStatus, users_setStatus, users_setStatus, users_setStatus, users_setStatus |
| Methods inherited from class com.google.code.facebookapi.BaseAdapter |
beginBatch, beginPermissionsMode, data_createObjectType, data_defineAssociation, data_defineObjectProperty, data_deleteObject, data_deleteObjects, data_dropObjectType, data_removeAssociatedObjects, data_removeAssociation, data_renameAssociation, data_renameObjectProperty, data_renameObjectType, data_setAssociation, data_setObjectProperty, data_setUserPreference, data_setUserPreferences, data_undefineAssociation, data_undefineObjectProperty, data_updateObject, endPermissionsMode, fbml_deleteCustomTags, fbml_registerCustomTags, getApiKey, getClient, getConnectTimeout, getRawResponse, getReadTimeout, getResponseFormat, getSecret, getServerUrl, profile_setInfo, profile_setInfoOptions, setCacheAppUser, setCacheSession, setCommunicationStrategy, setConnectTimeout, setReadTimeout, setServerUrl, setServerUrl, sms_sendMessage |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface com.google.code.facebookapi.IFacebookRestClient |
admin_getDailyMetrics, admin_getDailyMetrics, admin_getMetrics, admin_getMetrics, application_getPublicInfo, application_getPublicInfoByApiKey, application_getPublicInfoByCanvasName, application_getPublicInfoById, batch_run, beginBatch, beginPermissionsMode, connect_registerUsers, connect_unregisterUsers, dashboard_multiAddNews, dashboard_multiAddNews, dashboard_multiClearNews, dashboard_multiClearNews, data_createObjectType, data_defineAssociation, data_defineObjectProperty, data_deleteObject, data_deleteObjects, data_dropObjectType, data_getAssociationDefinition, data_getAssociationDefinitions, data_getCookies, data_getCookies, data_getCookies, data_getCookies, data_getObject, data_getObjectProperty, data_getObjects, data_getObjectType, data_getObjectTypes, data_getUserPreferences, data_removeAssociatedObjects, data_removeAssociation, data_renameAssociation, data_renameObjectProperty, data_renameObjectType, data_setAssociation, data_setObjectProperty, data_setUserPreference, data_setUserPreferences, data_undefineAssociation, data_undefineObjectProperty, data_updateObject, endPermissionsMode, events_get, events_get, events_getMembers, fbml_deleteCustomTags, fbml_getCustomTags, fbml_registerCustomTags, feed_getRegisteredTemplateBundleByID, feed_getRegisteredTemplateBundles, fql_query, friends_areFriends, friends_areFriends, friends_get, friends_get, friends_getAppUsers, friends_getList, friends_getLists, friends_getMutualFriends, friends_getMutualFriends, getApiKey, getConnectTimeout, getRawResponse, getReadTimeout, getResponseFormat, getSecret, getServerUrl, groups_get, groups_getMembers, notifications_get, pages_getInfo, pages_getInfo, pages_getInfo, pages_getInfo, payments_getOrders, permissions_checkAvailableApiAccess, permissions_checkGrantedApiAccess, 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_uploadToAlbum, photos_uploadToAlbum, photos_uploadWithCaption, photos_uploadWithCaption, profile_getFBML, profile_getFBML, profile_getFBML, profile_getFBML, profile_getInfo, profile_getInfoOptions, profile_setInfo, profile_setInfoOptions, setCacheAppUser, setCacheSession, setConnectTimeout, setReadTimeout, setServerUrl, setServerUrl, sms_sendMessage, stream_get, stream_getComments, stream_getFilters, users_getInfo, users_getInfo, users_getStandardInfo, users_getStandardInfo |
log
protected static org.apache.commons.logging.Log log
JAXB_CONTEXT
protected static javax.xml.bind.JAXBContext JAXB_CONTEXT
FacebookJaxbRestClientBase
public FacebookJaxbRestClientBase(ExtensibleClient client)
FacebookJaxbRestClientBase
public FacebookJaxbRestClientBase(java.lang.String apiKey,
java.lang.String secret)
- Constructor.
- Parameters:
apiKey - your Facebook API keysecret - your 'secret' Facebook key
FacebookJaxbRestClientBase
public FacebookJaxbRestClientBase(java.lang.String apiKey,
java.lang.String secret,
java.lang.String sessionKey)
- Constructor.
- Parameters:
apiKey - your Facebook API keysecret - your 'secret' Facebook keysessionKey - the session-id to use
FacebookJaxbRestClientBase
public FacebookJaxbRestClientBase(java.lang.String apiKey,
java.lang.String secret,
java.lang.String sessionKey,
boolean sessionSecret)
getJaxbContext
public javax.xml.bind.JAXBContext getJaxbContext()
setJaxbContext
public void setJaxbContext(javax.xml.bind.JAXBContext context)
initJaxbSupport
public static void initJaxbSupport()
getResponsePOJO
public java.lang.Object getResponsePOJO()
- Returns a JAXB object of the type that corresponds to the last API call made on the client. Each Facebook Platform API call that returns a Document object has a
JAXB response object associated with it. The naming convention is generally intuitive. For example, if you invoke the 'user_getInfo' API call, the associated JAXB
response object is 'UsersGetInfoResponse'.
An example of how to use this method:
FacebookRestClient client = new FacebookRestClient("apiKey", "secretKey", "sessionId");
client.friends_get();
FriendsGetResponse response = (FriendsGetResponse)client.getResponsePOJO();
List friends = response.getUid();
This is particularly useful in the case of API calls that return a Document object, as working with the JAXB response object is generally much simple than trying
to walk/parse the DOM by hand.
This method can be safely called multiple times, though note that it will only return the response-object corresponding to the most recent Facebook Platform API
call made.
Note that you must cast the return value of this method to the correct type in order to do anything useful with it.
- Returns:
- a JAXB POJO ("Plain Old Java Object") of the type that corresponds to the last API call made on the client. Note that you must cast this object to its
proper type before you will be able to do anything useful with it.
getResponsePOJO
public java.lang.Object getResponsePOJO(java.lang.String rawResponse)
parseCallResult
protected java.lang.Object parseCallResult(java.lang.Object rawResponse)
throws FacebookException
- Parses the result of an API call from XML into JAXB Objects.
- Parameters:
data - an InputStream with the results of a request to the Facebook serversmethod - the method
- Returns:
- a JAXB Object
- Throws:
FacebookException - if data represents an error
java.io.IOException - if data is not readable
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
Copyright © 2010. All Rights Reserved.