Versions Compared

Key

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

...

Anchor
postPhotoToAlbum
postPhotoToAlbum
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.

...

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.

Info

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.

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>