Creating a Simple Custom XML Syndication

To create a simple custom XML syndication:

  1. Create an advanced syndication. The following example creates the "My Custom XML Feed" advanced syndication.
    [POST]/v2/syndications{  
       "name":"My Custom XML Feed",
       "type":"advanced"
    }

    Backlot returns a response similar to the following, which includes the URL where the feed can be accessed.

    {  
       "name":"My Custom XML Feed",
       "include_encodings":[  
    
       ],
       "destination_url":"",
       "require_access_key":false,
       "title":"",
       "include_labels":[  
    
       ],
       "asset_types":[  
          "video",
          "ad"
       ],
       "syndication_url":"http://api.ooyala.com/syndications/6b6e72dd71bd4fa/feed?pcode=Y4cG06BlqYMLIjPGyv1NbacSK-x3",
       "id":"6b6e72dd71bd4fa",
       "include_all_content":false,
       "type":"advanced",
       "description":""
    }
    Note:

    Try out the code samples using your account credentials in the Ooyala Scratchpad. For information about using the Scratchpad, see Practice Making Requests with the Scratchpad. To launch the scratchpad, go to Ooyala API Scratchpad.

  2. Create a Universal Syndication Template Language (USTL) template. The following template creates a simple list of assets, which specifies the name, description, and length of each asset.
    <feed header>List of My Assets</feed header>
    {% for asset in assets %}
      <item>
        <title> {{asset.name}} </title>
        <description> {{asset.description}} </description>
        <length> {{asset.duration}} minutes</length>
      </item>
    {% endfor assets %}
    
        
    Note: For more information about USTL, see the Universal Syndication Template Language section of the Backlot API Reference.
  3. Attach the Universal Syndication Template Language (USTL) template The following example attaches the template to the newly created syndication.
    [PUT]/v2/syndications/6b6e72dd71bd4fa/template 
     <feed header>List of My Assets</feed header>{  
       % for asset in assets %
    }<item> 
     <title>{  
       {  
          asset.name
       }
    }</title> 
     <description>{  
       {  
          asset.description
       }
    }</description> 
     <length>{  
       {  
          asset.duration
       }
    }minutes</length> 
     </item>{  
       % endfor assets %
    }
    Backlot returns a 200 response.
  4. For the feed to contain videos and other assets, you must add labels. Whenever you add a label to an asset that is associated with a feed, the asset is automatically added to the feed. The following example adds the 638aed2a18734375b and c42b225963ad481b9 labels to the 6b6e72dd71bd4fa syndication.
    [PATCH]/v2/syndications/6b6e72dd71bd4fa{  
       "include_labels":[  
          "638aed2a18734375b",
          "c42b225963ad481b9"
       ]
    }

    Backlot returns a response similar to the following.

    {  
       "name":"My iPhone Feed",
       "include_encodings":[  
    
       ],
       "destination_url":"",
       "require_access_key":false,
       "title":"",
       "include_labels":[  
          "638aed2a18734375b",
          "c42b225963ad481b9"
       ],
       "asset_types":[  
          "video",
          "ad"
       ],
       "syndication_url":"http://api.ooyala.com/syndications/6b6e72dd71bd4fa/feed?pcode=Y4cG06BlqYMLIjPGyv1NbacSK-x3",
       "id":"6b6e72dd71bd4fa",
       "include_all_content":false,
       "type":"iphone",
       "description":""
    }
    Note:

    Try out the code samples using your account credentials in the Ooyala Scratchpad. For information about using the Scratchpad, see Practice Making Requests with the Scratchpad. To launch the scratchpad, go to Ooyala API Scratchpad.

  5. To view the results of the feed, open the syndication URL. If you do not have it, you can get it by making a get request against the syndication ID. In this example, the http://api.ooyala.com/syndications/6b6e72dd71bd4fa/feed?pcode=Y4cG06BlqYMLIjPGyv1NbacSK-x3 URL returns results similar to the following:
    <feed header>List of My Assets</feed header>
    <item>
      <title>Presidential Speech #125784</title>
      <video_info>The president said something important today about something that happened.</video_info>
    </item>
      <title>Presidential Speech #125785</title>
      <video_info>The president said something important today about something that should happen.</video_info>
    </item>
    
        

Was this article helpful?