Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

For a sample proxy service that illustrates how to work with albums, see Sample configuration.

OperationDescription
createAlbumCreates an album.
getAlbumDetailsReturns details of an album.
postPhotoToAlbumAdds photos to an album.

Operation details

This section provides details on each of the operations.

...

  • albumId: The ID of the album.
  • fields: The fields which belongs to an objectthat you need to retrieve.
Anchor
request
request
Sample request

Following is a sample REST request for the getAlbumDetails methodthat can be handled by the getAlbumDetails operation.

Code Block
languagehtml/xml
titleSample Request for getAlbumDetails
{
	"apiUrl":"https://graph.facebook.com",
	"apiVersion":"v2.4",
	"accessToken":"CAACEdEose0cBAPas3EqVsnzvtvEyZAPdrXEgdRRHEYEa6wZBJzupmqxJQXnxQ75EHeyg9cZBa2lOgObUpdmTTfQLqryHHjAV5bgd7njEML9uZBAaNuYl6q1KjlCteifZA9THGTRsZBZBk2LQQEaaHZCxQmUsYh3RMghs9vDGhOZC0Y8ZAdVpRl3usfCRvitQtLNHPNKOWzy59peAZDZD",
	"albumId":"10150146071791729"
}

...

Anchor
postPhotoToAlbum
postPhotoToAlbum
Adding photos to an album

This method allows users to post The postPhotoToAlbum operation adds photos to the a specified album. This does not require init to <facebook.init> to be called before the operation.  Refer to multipart processing for detailed informationFor information on why you do not need to call <facebook.init> before this operation, see multipart processing.

Code Block
languagehtml/xml
titlepostPhotoToAlbum
<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 on behalf of a user.

  • apiUrl: Indicates the The URL of the Facebook API.

  • apiVersion: Version 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 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.

...

Following is a sample REST request for the postPhotoToAlbum methodthat can be handled by the postPhotoToAlbum operation.

Code Block
languagehtml/xml
titleSample Request for postPhotoToAlbum
 curl -X POST \
     -d "source=%7Bimage-data%7D" \
        http://localhost:8280/services/facebook_postPhotoToAlbum?album_id=3434523334&message=Test image

...

Anchor
sample
sample

Sample configuration

Following is a sample proxy service that illustrates how to connect to Facebook with the init operation the init operation and then use the getAlbumDetails operation to getAlbumDetails operation to create an album. The sample request for this proxy can be found in in  getAlbumDetails sample request . You can use this sample as a template for using other operations in this category.

Info


As a best practice,  create create a separate sequence for handling the response payload for errors. In the following sample, this the sequence that handles errors is "faultHandlerSeq".


Code Block
languagexml
titlegetAlbumDetails
<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>