Versions Compared

Key

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

To use the Facebook connector, add the <facebook.init> element in your configuration before carrying out any other Faceboook operation. Most Graph API requests require the use of access tokens that the client application can generate by implementing Facebook Login .

The basic procedure to get a user token is for the client to request access and permission via the Facebook Login dialog. After the user is authenticated, the user is redirected to the user consent dialog. On completion of consent, the access token is returned to the client. For more information, refer to access tokens and how to generate them using Facebook Login.

...

Code Block
titleSample request for getPageAccessToken
{
	"apiUrl":"https://graph.facebook.com",

	"apiVersion":"v2.5",
	"accessToken":"CAACEdEose0cBAHr8S2hVPNpCy1DbIuGHlmwbWubyR6YSr0wxgD0ncZBYfGrRvuZC88KqChF44ZAhMRZCPUeYM6xQaHuf1pCzfAwVMrPT4GUZAIOwbc2aBRb5BD6YlA8YKBgKInK08368Xh78arj3ORrUNZCyCc",
	"pageId":"102898890060274"
}

...

With the current features of the ESB, the multipart/form-data received cannot be processed inside the ESB. Hence, the ESB should be in a content unaware status, which you can achieve using a pass-through proxy, and the user Therefore, to perform operations associated with multipart data, you must build the message from the client end and send it to the a pass through proxy. Additional query parameters such as albumId, photoId, pageId, etc. are to be sent in the form of a URL parameter. These parameters can can be configured as URL parameters in the relevant connector operation. These query parameters should be retrieved from this the URL and handled in the proxy.

For example, if you need to retrieve the album ID needs to be retrieved from this the URL, then it is should be called byas follows:

Code Block
<albumId>{$url:album_id}</albumId>

Since the endpoint is constructed inside the proxy, it is not necessary to call the init method for multipart operations.

Sample proxy to handle multipart operations

Code Block
languagehtml/xml
titlepostPhotoToAlbum
<proxy xmlns="http://ws.apache.org/ns/synapse"
       name="facebook_postPhotoToAlbum"
       transports="https,http"
       statistics="disable"
       trace="disable"
       startOnLoad="true">
   <target>
      <inSequence>
         <facebook.postPhotoToAlbum>
            <albumId>{$url:album_id}</albumId>
			<apiUrl>https://graph.facebook.com</apiUrl>
			<apiVersion>{$url:apiVersion}</apiVersion>
			<accessToken>{$url:accessToken}</accessToken>
         </facebook.postPhotoToAlbum>
         <respond/>
      </inSequence>
      <outSequence>
         <send/>
      </outSequence>
   </target>
   <description/>
</proxy>
Tip

...

Since the endpoint is constructed inside the proxy, it is not necessary to call the init method for multipart operations.

Sample request
Code Block
languagehtml/xml
curl -X POST \
    -d "source=%7Bimage-data%7D" \
       http://localhost:8280/services/facebook_postPhotoToAlbum/?album_id=1403293536601941

Additional information

 Ensure that the following Axis2 configurations are added and enabled in the <ESB_HOME>\/repository\/conf\/axis2\/axis2.xml file.

Required message formatters

...

Code Block
languagexml
titlemessageBuilders
<messageBuilder contentType="multipart/form-data" class="org.wso2.carbon.relay.BinaryRelayBuilder"/>

The Now that you have connected to Facebook, use the information in the following topics describe how to perform various operations with the Facebook connector: .

Child pages (Children Display)