This site contains the documentation that is relevant to older WSO2 product versions and offerings.
For the latest WSO2 documentation, visit https://wso2.com/documentation/.

Working with Videos in Facebook



Overview

The following operations allow you to work with videos. Click an operation name to see details on how to use it. 

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

OperationDescription
getVideoDetailsRetrieves details of a particular video.
uploadVideoUploads a video.

Operation details

This section provides details on each of the operations.

Retrieving video details

The getVideoDetails operation retrieves details of a video based on the specified video ID.

getVideoDetails
<facebook.getVideoDetails>
	<videoId>{$ctx:videoId}</videoId>
</facebook.getVideoDetails>
Properties
  •  videoId: The ID of the video that you want to retrieve.

Further references to the fields that should be passed into the video object are given in Video objects.

Sample request

Following is a sample REST request that can be handled by the getVideoDetails operation.

Sample Request for getVideoDetails
{
"apiUrl":"https://graph.facebook.com",
"apiVersion":"v2.4",
"accessToken":"CAAGZCMZA2ZCZBjIBAGggngSr83BQeKyZBURGscejHaGc8yI6524yDPv6lsamw2ua7Hmh13DT9YPTiM2hpJFXmXZBLlxeqtpSrmenGItIZAJmQNKkyUdnGwZACJaXu7Cyp0ZCiD4AViO5t1RTSzg8RWsVEad5mCsDfafzJ1tYYMQZARpDyMiZB3FQ4R3V7gs2j7j0igZD",
"videoId":"1842716434144",
"connection":"",
"fields":""
}

Related Facebook documentation: 

https://developers.facebook.com/docs/graph-api/reference/user/videos#read 

Uploading video

The uploadVideo operation uploads a video to a post, wall, page or any other specified resource.

Note

This operation 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.

uploadVideo
<facebook.uploadVideo>
    <resourceId>{$url:resourceId}</resourceId>
    <apiUrl>{$url:apiUrl}</apiUrl>
    <apiVersion>{$url:apiVersion}</apiVersion>
    <accessToken>{$url:accessToken}</accessToken>
    <title>{$url:title}</title>
    <description>{$url:description}</description>
    <unpublishedContentType>{$url:unpublishedContentType}</unpublishedContentType>
    <fileUrl>{$url:fileUrl}</fileUrl>
    <uploadPhase>{$url:uploadPhase}</uploadPhase>
    <fileSize>{$url:fileSize}</fileSize>
    <startOffset>{$url:startOffset}</startOffset>
    <uploadSessionId>{$url:uploadSessionId}</uploadSessionId>
    <contentCategory>{$url:contentCategory}</contentCategory>
    <embeddable>{$url:embeddable}</embeddable>
    <backdatedPost>{$url:backdatedPost}</backdatedPost>
    <callToAction>{$url:callToAction}</callToAction>
    <feedTargeting>{$url:feedTargeting}</feedTargeting>
    <published>{$url:published}</published>
    <scheduledPublishTime>{$url:scheduledPublishTime}</scheduledPublishTime>
    <targeting>{$url:targeting}</targeting>
    <noStory>{$url:noStory}</noStory>
</facebook.uploadVideo>                  
Properties
  • resourceId: The ID of the resource for which you want upload a video. This can either be an eventId, pageId or user_id.

  • apiUrl: The URL of the Facebook API.

  • apiVersion: The version of the Facebook API.

  • accessToken: The access token that allows making requests to the API on behalf of a user.

  • title: The title of the video.

  • description: The description of the video.

  • unpublishedContentType: The type of the unpublished content. Possible values are scheduled, draft or ads_post.

  • fileUrl: The URL of the video file.

  • uploadPhase: Type of chunked upload request.

  • fileSize: The size of the entire video file in bytes.

  • startOffset: The start byte position of the file chunk.

  • uploadSessionId: The ID of the chunked upload session.

  • contentCategory: The content category of the video.

  • embeddable: Indicates whether the video is embeddable or not.

  • backdatedPost: Indicates whether backdated video posting is allowed.

  • callToAction: The call to action for someone viewing the video, such as Reply.

  • feedTargeting: The object that controls news feed targeting for this content.

  • published: Indicates whether a post about this video is published.

  • scheduledPublishTime: The time that the page post about this video should go live.

  • targeting: The object that limits the audience for this content.

  • noStory: If set to true, this suppresses the feed and timeline story.

Sample request (cURL)

Following is a sample request that can be handled by the uploadVideo operation. 

Sample Request for uploadVideo
curl -X POST \-d "source=%7Bvideo-data%7D" \http://localhost:8280/services/facebook_uploadVideo?resourceId=102898890060274&apiUrl=https://graph.facebook.com&apiVersion=v2.4&accessToken=CAACEdEose0cBAG0O6EcLDgWzrr6iLVdmNQ5RAzsOdkM3PrpLPpR64PoizfKT59BK0MaWhJEztbZCXKaCeZBCMZBLfKjZCZBk3ejt4NMfOqtZABXV27IB1BzoEErsuCIRuhpavBBHLqBC9B7MZBZBr57ZBcJCappNsoJkZBvJE8LF1OAfgwrJiHjUOMbnz3NNLcIKkZD
Related Facebook documentation: 

https://developers.facebook.com/docs/graph-api/reference/user/videos#publish

https://developers.facebook.com/docs/graph-api/reference/page/videos/#publish  

https://developers.facebook.com/docs/graph-api/reference/event/videos#publish

Sample configuration

Following is a sample proxy service that illustrates how to connect to Facebook with the init operation, and then use the getVideoDetails operation. The sample request for this proxy can be found in getVideoDetails 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 to handle response payload errors. In the following sample, the sequence that handles errors is the faultHandlerSeq.


getVideoDetails
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
       name="facebook_getVideoDetails"
       transports="https,http"
       statistics="disable"
       trace="disable"
       startOnLoad="true">
   <target>
      <inSequence onError="faultHandlerSeq">
         <property name="apiUrl"
                   expression="json-eval($.apiUrl)"/>
		 <property name="apiVersion"
                   expression="json-eval($.apiVersion)"/>
         <property name="accessToken"
                   expression="json-eval($.accessToken)"/>
         <property name="connection"
                   expression="json-eval($.connection)"/>
         <property name="fields"
                   expression="json-eval($.fields)"/>
         <property name="videoId"
                   expression="json-eval($.videoId)"/>
         <facebook.init>
            <accessToken>{$ctx:accessToken}</accessToken>
            <apiUrl>{$ctx:apiUrl}</apiUrl>
			<apiVersion>{$ctx:apiVersion}</apiVersion>            
         </facebook.init>
         <facebook.getVideoDetails>
            <videoId>{$ctx:videoId}</videoId>
			<connection>{$ctx:connection}</connection>
            <fields>{$ctx:fields}</fields>
         </facebook.getVideoDetails>
         <respond/>
      </inSequence>
      <outSequence>
         <send/>
      </outSequence>
   </target>
   <description/>
</proxy>