public class FacebookTemplate extends org.springframework.social.oauth2.AbstractOAuth2ApiBinding implements Facebook
This is the central class for interacting with Facebook.
There are some operations, such as searching, that do not require OAuth
authentication. In those cases, you may use a FacebookTemplate that is
created through the default constructor and without any OAuth details.
Attempts to perform secured operations through such an instance, however,
will result in NotAuthorizedException being thrown.
GRAPH_API_URL| Constructor and Description |
|---|
FacebookTemplate(String accessToken)
Create a new instance of FacebookTemplate.
|
FacebookTemplate(String accessToken,
String applicationNamespace) |
FacebookTemplate(String accessToken,
String applicationNamespace,
String appId) |
| Modifier and Type | Method and Description |
|---|---|
AchievementOperations |
achievementOperations()
API for working with achievements.
|
CommentOperations |
commentOperations()
API for reading and posting comments.
|
protected void |
configureRestTemplate(RestTemplate restTemplate) |
void |
delete(String objectId)
Deletes an object.
|
void |
delete(String objectId,
String connectionType)
Deletes an object connection.
|
void |
delete(String objectId,
String connectionType,
MultiValueMap<String,String> data)
Deletes an object connection.
|
EventOperations |
eventOperations()
API for performing operations on events.
|
FeedOperations |
feedOperations()
API for performing operations on feeds.
|
<T> PagedList<T> |
fetchConnections(String objectId,
String connectionType,
Class<T> type,
MultiValueMap<String,String> queryParameters)
Fetches connections, extracting them into a collection of the given Java type
Requires appropriate permission to fetch the object connection.
|
<T> PagedList<T> |
fetchConnections(String objectId,
String connectionType,
Class<T> type,
MultiValueMap<String,String> queryParameters,
String... fields)
Fetches connections, extracting them into a collection of the given Java type
Requires appropriate permission to fetch the object connection.
|
<T> PagedList<T> |
fetchConnections(String objectId,
String connectionType,
Class<T> type,
String... fields)
Fetches connections, extracting them into a collection of the given Java type
Requires appropriate permission to fetch the object connection.
|
byte[] |
fetchImage(String objectId,
String connectionType,
ImageType type)
Fetches an image as an array of bytes.
|
byte[] |
fetchImage(String objectId,
String connectionType,
Integer width,
Integer height)
Fetches an image as an array of bytes.
|
<T> T |
fetchObject(String objectId,
Class<T> type)
Fetches an object, extracting it into the given Java type
Requires appropriate permission to fetch the object.
|
<T> T |
fetchObject(String objectId,
Class<T> type,
MultiValueMap<String,String> queryParameters)
Fetches an object, extracting it into the given Java type
Requires appropriate permission to fetch the object.
|
<T> T |
fetchObject(String objectId,
Class<T> type,
String... fields)
Fetches an object, extracting it into the given Java type
Requires appropriate permission to fetch the object.
|
<T> PagedList<T> |
fetchPagedConnections(String objectId,
String connectionType,
Class<T> type,
MultiValueMap<String,String> queryParameters) |
FriendOperations |
friendOperations()
API for performing operations with a user's set of friends.
|
String |
getApplicationNamespace() |
String |
getBaseGraphApiUrl() |
protected MappingJackson2HttpMessageConverter |
getJsonMessageConverter() |
protected org.springframework.social.oauth2.OAuth2Version |
getOAuth2Version() |
GroupOperations |
groupOperations()
API for performing operations on groups.
|
LikeOperations |
likeOperations()
API for performing operations against user likes and interests.
|
MediaOperations |
mediaOperations()
API for performing operations on albums, photos, and videos.
|
OpenGraphOperations |
openGraphOperations()
API for working with OpenGraph actions.
|
PageOperations |
pageOperations()
API for working with Facebook pages.
|
void |
post(String objectId,
MultiValueMap<String,Object> data)
Publishes data to an object.
|
void |
post(String objectId,
String connectionType,
MultiValueMap<String,Object> data)
Publishes data to an object's connection.
|
String |
publish(String objectId,
String connectionType,
MultiValueMap<String,Object> data)
Publishes data to an object's connection.
|
RestOperations |
restOperations()
Returns the underlying
RestOperations object allowing for consumption of Facebook endpoints that may not be otherwise covered by the API binding. |
void |
setApiVersion(String apiVersion)
Set the Graph API version (e.g., "2.5").
|
void |
setRequestFactory(ClientHttpRequestFactory requestFactory) |
SocialContextOperations |
socialContextOperations()
API for working with social contexts.
|
TestUserOperations |
testUserOperations()
API for working with test users on Facebook.
|
UserOperations |
userOperations()
API for performing operations on Facebook user profiles.
|
afterPropertiesSet, getByteArrayMessageConverter, getFormMessageConverter, getMessageConverters, getRestTemplate, isAuthorized, postConstructionConfiguration, postProcesspublic FacebookTemplate(String accessToken)
accessToken - An access token given by Facebook after a successful OAuth 2 authentication (or through Facebook's JS library).public void setRequestFactory(ClientHttpRequestFactory requestFactory)
setRequestFactory in class org.springframework.social.oauth2.AbstractOAuth2ApiBindingpublic void setApiVersion(String apiVersion)
apiVersion - the API version. Default is "2.5".public AchievementOperations achievementOperations()
FacebookachievementOperations in interface FacebookAchievementOperationspublic UserOperations userOperations()
FacebookuserOperations in interface FacebookUserOperationspublic LikeOperations likeOperations()
FacebooklikeOperations in interface FacebookLikeOperationspublic FriendOperations friendOperations()
FacebookfriendOperations in interface FacebookFriendOperationspublic FeedOperations feedOperations()
FacebookfeedOperations in interface FacebookFeedOperationspublic GroupOperations groupOperations()
FacebookgroupOperations in interface FacebookGroupOperationspublic CommentOperations commentOperations()
FacebookcommentOperations in interface FacebookCommentOperationspublic EventOperations eventOperations()
FacebookeventOperations in interface FacebookEventOperationspublic MediaOperations mediaOperations()
FacebookmediaOperations in interface FacebookMediaOperationspublic PageOperations pageOperations()
FacebookpageOperations in interface FacebookPageOperationspublic RestOperations restOperations()
FacebookRestOperations object allowing for consumption of Facebook endpoints that may not be otherwise covered by the API binding.
The RestOperations object returned is configured to include an OAuth 2 "Authorization" header on all requests.restOperations in interface Facebookpublic OpenGraphOperations openGraphOperations()
FacebookopenGraphOperations in interface FacebookOpenGraphOperationspublic SocialContextOperations socialContextOperations()
FacebooksocialContextOperations in interface FacebookSocialContextOperationspublic String getApplicationNamespace()
getApplicationNamespace in interface FacebookgetApplicationNamespace in interface GraphApipublic TestUserOperations testUserOperations()
FacebooktestUserOperations in interface FacebookTestUserOperationspublic <T> T fetchObject(String objectId, Class<T> type)
GraphApifetchObject in interface GraphApiT - The Java type to bind the Facebook object toobjectId - the Facebook object's IDtype - the Java type to fetchpublic <T> T fetchObject(String objectId, Class<T> type, String... fields)
GraphApifetchObject in interface GraphApiT - The Java type to bind the Facebook object toobjectId - the Facebook object's IDtype - the Java type to fetchfields - the fields to include in the response.public <T> T fetchObject(String objectId, Class<T> type, MultiValueMap<String,String> queryParameters)
GraphApifetchObject in interface GraphApiT - The Java type to bind the Facebook object toobjectId - the Facebook object's IDtype - the Java type to fetchqueryParameters - query parameters to include in the requestpublic <T> PagedList<T> fetchConnections(String objectId, String connectionType, Class<T> type, String... fields)
GraphApifetchConnections in interface GraphApiT - The Java type to bind the Facebook object toobjectId - the ID of the object to retrieve the connections for.connectionType - the connection name.type - the Java type of each connection.fields - the fields to include in the response.public <T> PagedList<T> fetchConnections(String objectId, String connectionType, Class<T> type, MultiValueMap<String,String> queryParameters)
GraphApifetchConnections in interface GraphApiT - The Java type to bind the Facebook object toobjectId - the ID of the object to retrieve the connections for.connectionType - the connection name.type - the Java type of each connection.queryParameters - query parameters to include in the requestpublic <T> PagedList<T> fetchPagedConnections(String objectId, String connectionType, Class<T> type, MultiValueMap<String,String> queryParameters)
public <T> PagedList<T> fetchConnections(String objectId, String connectionType, Class<T> type, MultiValueMap<String,String> queryParameters, String... fields)
GraphApifetchConnections in interface GraphApiT - The Java type to bind the Facebook object toobjectId - the ID of the object to retrieve the connections for.connectionType - the connection name.type - the Java type of each connection.queryParameters - query parameters to include in the requestfields - the fields to include in the response.public String getBaseGraphApiUrl()
getBaseGraphApiUrl in interface GraphApipublic byte[] fetchImage(String objectId, String connectionType, ImageType type)
GraphApifetchImage in interface GraphApiobjectId - the object IDconnectionType - the connection nametype - the type of image to retrieve (eg., small, normal, large, or square)public byte[] fetchImage(String objectId, String connectionType, Integer width, Integer height)
GraphApifetchImage in interface GraphApiobjectId - the object IDconnectionType - the connection namewidth - desired width of the image (optional)height - desired height of the image (optional)public String publish(String objectId, String connectionType, MultiValueMap<String,Object> data)
GraphApipublic void post(String objectId, MultiValueMap<String,Object> data)
GraphApipublic void post(String objectId, String connectionType, MultiValueMap<String,Object> data)
GraphApipublic void delete(String objectId)
GraphApipublic void delete(String objectId, String connectionType)
GraphApipublic void delete(String objectId, String connectionType, MultiValueMap<String,String> data)
GraphApiprotected org.springframework.social.oauth2.OAuth2Version getOAuth2Version()
getOAuth2Version in class org.springframework.social.oauth2.AbstractOAuth2ApiBindingprotected void configureRestTemplate(RestTemplate restTemplate)
configureRestTemplate in class org.springframework.social.oauth2.AbstractOAuth2ApiBindingprotected MappingJackson2HttpMessageConverter getJsonMessageConverter()
getJsonMessageConverter in class org.springframework.social.oauth2.AbstractOAuth2ApiBinding