Overview
The following operations allow you to work with albums. Click an operation name to see details on how to use it.
For a sample proxy service that illustrates how to work with albums, see Sample configuration.
Operation | Description |
---|---|
createAlbum | Creates an album. |
getAlbumDetails | Returns details of an album. |
postPhotoToAlbum | Adds photos to an album. |
Operation details
This section provides details on each of the operations.
Creating an album
Through this method, a user is allowed to create an album.
<facebook.createAlbum> <userId>{$ctx:userId}</userId> <message>{$ctx:message}</message> <name>{$ctx:name}</name> <privacy>{$ctx:privacy}</privacy> <location>{$ctx:location}</location> <isDefault>{$ctx:isDefault}</isDefault> <place>{$ctx:place}</place> </facebook.createAlbum>
Properties
userId: The Object ID that you are creating an album for(Default me).
name: Required - The name given to the album.
message: The description of the album, which will show up in news feed stories as the status message.
-
privacy
: Privacy setting for the album, which is an Object. Values could be EVERYONE, ALL_FRIENDS, FRIENDS_OF_FRIENDS, CUSTOM and SELF. For further information on the privacy parameter, refer to https://developers.facebook.com/docs/reference/api/privacy-parameter location: A text location of the album for non-page locations.
isDefault: True indicates that the request will create the application specific album.
place: The ID of a location page to tag the album with.
Sample request
Following is a sample REST request for the createAlbum method.
{ "apiUrl":"https://graph.facebook.com", "apiVersion":"v2.4", "accessToken":"CAACEdEose0cBAE0MQc25uyfYTS8zsZCu3wbJEZAcGc1Mzle1LbzJHI8LVAhvpWsSkQq4SrZAzZBruv3yWSoJZCSFFlWeal2sFOFplmjPfs39mxJLSF8YxPePkeuCU7cjYqEKCtW3qTEy6XUWHD1T1ush5Rhj85ZBEa94E7pP7XuuITLsFweZBoMMRX0QyGGWw0ZD", "message":"this is a test message", "name":"WSO2 connector", "privacy":"{value:'EVERYONE'}" }
Related Facebook documentation:
https://developers.facebook.com/docs/graph-api/reference/user/albums/#publish
Retrieving album details
This method retrieves details of the user album.
<facebook.getAlbumDetails> <albumId>{$ctx:albumId}</albumId> <fields>{$ctx:fields}</fields> <connection>{$ctx:connection}</connection> </facebook.getAlbumDetails>
Properties
albumId: This is the ID of the album.
fields: The fields which belongs to an object.
Sample request
Following is a sample REST request for the getAlbumDetails method.
{ "apiUrl":"https://graph.facebook.com", "apiVersion":"v2.4", "accessToken":"CAACEdEose0cBAPas3EqVsnzvtvEyZAPdrXEgdRRHEYEa6wZBJzupmqxJQXnxQ75EHeyg9cZBa2lOgObUpdmTTfQLqryHHjAV5bgd7njEML9uZBAaNuYl6q1KjlCteifZA9THGTRsZBZBk2LQQEaaHZCxQmUsYh3RMghs9vDGhOZC0Y8ZAdVpRl3usfCRvitQtLNHPNKOWzy59peAZDZD", "albumId":"10150146071791729" }
Related Facebook documentation :
https://developers.facebook.com/docs/graph-api/reference/user/albums/#read
Adding photos to an album
This method allows users to post photos to the album. This does not require init to be called before the operation. Refer to multipart processing for detailed information.
<facebook.postPhotoToAlbum> <albumId>{$url:albumId}</albumId> <apiUrl>{$url:apiUrl}</apiUrl> <apiVersion>{$url:apiVersion}</apiVersion> <accessToken>{$url:accessToken}</accessToken> <message>{$url:message}</message> <location>{$url:location}</location> <noStory>{$url:noStory}</noStory> <photoUrl>{$url:photoUrl}</photoUrl> <place>{$url:place}</place> </facebook.postPhotoToAlbum>
Properties
accessToken: The access token allows making requests to the API on behalf of a user
apiUrl: Indicates the URL of the Facebook API.
apiVersion: Version of the Facebook API
albumId: The unique identifier of the album.
location: A text location of the album for non-page locations.
message: The description of the photo.
noStory: If set to true, this will suppress the feed story that is automatically generated on a person's profile when they upload a photo using your app.
- photoUrl: The URL of a photo that is already uploaded to the internet.
place: Page ID of a place associated with the Photo.
Sample request (Curl)
Following is a sample REST request for the postPhotoToAlbum method.
curl -X POST \ -d "source=%7Bimage-data%7D" \ http://localhost:8280/services/facebook_postPhotoToAlbum?album_id=3434523334&message=Test image
Related Facebook documentation:
https://developers.facebook.com/docs/graph-api/reference/album/photos#publish
Sample configuration
Following is a sample proxy service that illustrates how to connect to Facebook with the init operation and use the getAlbumDetails operation to create an album. The sample request for this proxy can be found in getAlbumDetails sample request . You can use this sample as a template for using other operations in this category.
As a best practice, create a separate sequence for handling the response payload for errors. In the following sample, this sequence is "faultHandlerSeq".
<proxy xmlns="http://ws.apache.org/ns/synapse" name="facebook_getAlbumDetails" transports="https,http" statistics="disable" trace="disable" startOnLoad="true"> <target> <inSequence onError="faultHandlerSeq"> <property name="apiUrl" expression="json-eval($.apiUrl)"/> <property name="accessToken" expression="json-eval($.accessToken)"/> <property name="apiVersion" expression="json-eval($.apiVersion)"/> <property name="albumId" expression="json-eval($.albumId)"/> <property name="fields" expression="json-eval($.fields)"/> <property name="connection" expression="json-eval($.connection)"/> <facebook.init> <apiUrl>{$ctx:apiUrl}</apiUrl> <apiVersion>{$ctx:apiVersion}</apiVersion> <accessToken>{$ctx:accessToken}</accessToken> </facebook.init> <facebook.getAlbumDetails> <albumId>{$ctx:albumId}</albumId> <fields>{$ctx:fields}</fields> <connection>{$ctx:connection}</connection> </facebook.getAlbumDetails> <respond/> </inSequence> <outSequence> <property name="messageType" value="application/json" scope="axis2"/> <send/> </outSequence> </target> </proxy>