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
The createAlbum
operation creates a new album based on the specified details.
<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 profile for which you want to create the album.name
: Required - The title of the album.message
: The description of the album. This is what appears in news feed stories below the title of the album.privacy
: The privacy setting for the album. Possible values are EVERYONE, ALL_FRIENDS, FRIENDS_OF_FRIENDS, CUSTOM and SELF. For more information on the privacy parameter, see https://developers.facebook.com/docs/reference/api/privacy-parameter.location
: The textual location of the album for non-page locations.isDefault
: Set totrue
if you want to create an application specific album.place
: The ID of a location page to tag the album with.
Sample request
Following is a sample REST request that can be handled by the createAlbum
operation.
{ "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
The getAlbumDetails
operation retrieves details of a specific user album.
<facebook.getAlbumDetails> <albumId>{$ctx:albumId}</albumId> <fields>{$ctx:fields}</fields> <connection>{$ctx:connection}</connection> </facebook.getAlbumDetails>
Properties
albumId
: The ID of the album that you want to retrieve.fields
: The fields of the album that you want to retrieve.
Sample request
Following is a sample REST request that can be handled by the getAlbumDetails
operation.
{ "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
The postPhotoToAlbum
operation adds photos to a specified album. This does not require <facebook.init>
to be called before the operation. For information on why you do not need to call <facebook.init>
before this operation, see multipart processing.
<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 that allows making requests to the API.apiUrl
: The URL of the Facebook API.apiVersion
: The 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 suppresses 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
: The page ID of a place associated with the photo.
Sample request (Curl)
Following is a sample REST request that can be handled by the postPhotoToAlbum
operation.
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 then 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, the sequence that handles errors 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>