Error message

User warning: The following module is missing from the file system: fast_404. For information about how to fix this, see the documentation page. in _drupal_trigger_error_with_delayed_logging() (line 1143 of /mnt/www/html/ooyala/docroot/includes/bootstrap.inc).

Código de ejemplo de la API de Backlot

Aquí ofrecemos un código de ejemplo en PHP y Ruby.

PHP

<?php

// You can find your Partner and Secret codes under the Developers
// area of the Backlot Account tab

define('OOYALA_PARTNER_CODE', '<Your Partner Code>');
define('OOYALA_SECRET_CODE', '<Your Secret Code>');

class OoyalaBacklotAPI
{

  static function query($params)
  {
    return OoyalaBacklotAPI::send_request('query', $params);
  }

  static function query_thumbnails($params)
  {
    return OoyalaBacklotAPI::send_request('thumbnails', $params);
  }

  static function update($params)
  {
    return OoyalaBacklotAPI::send_request('edit', $params);
  }

  static function labels($params)
  {
    return OoyalaBacklotAPI::send_request('labels', $params);
  }

  static function metadata($params)
  {
    return OoyalaBacklotAPI::send_request('metadata', $params);
  }

  private static function send_request($request_type, $params)
  {
    // Add an expire time of 15 minutes unless otherwise specified
    if (!array_key_exists('expires', $params)) {
      $params['expires'] = time() + 900;
    }

    $string_to_sign = OOYALA_SECRET_CODE;
    $url = 'http://api.ooyala.com/partner/'.$request_type.'?pcode='.OOYALA_PARTNER_CODE;
    $keys = array_keys($params);
    sort($keys);

    foreach ($keys as $key) {
      $string_to_sign .= $key.'='.$params[$key];
      $url .= '&'.rawurlencode($key).'='.rawurlencode($params[$key]);
    }

    $digest = hash('sha256', $string_to_sign, true);
    $signature = ereg_replace('=+$', '', trim(base64_encode($digest)));
    $url .= '&signature='.rawurlencode($signature);

    print "$url\n";

    return file_get_contents($url);
  }
}

// A few examples
$liveContent = OoyalaBacklotAPI::query(array('status' => 'live'));

$lifetimeStats = OoyalaBacklotAPI::query(array('statistics' => '1d,2d,7d,28d,30d,31d,lifetime', 'status' => 'live'));

$allTrailers = OoyalaBacklotAPI::query(array('label[0]' => 'trailers'));

$specificVideo = OoyalaBacklotAPI::query(array('embedCode' => 'plajrfuW5PS5rgc-kuc9ZWtFtdnYpfiK'));


$thumbnails = OoyalaBacklotAPI::query_thumbnails(array('embedCode' => 'plajrfuW5PS5rgc-kuc9ZWtFtdnYpfiK','range' =>
'0-99', 'resolution' => '320x240'));


$titleAndPause = OoyalaBacklotAPI::update(array('title' => 'updated title', 'status' => 'paused', 'embedCode' =>
'dhbjM6U-1s7YkieEwJRepTrYiPed8dPe'));

$hostedAt = OoyalaBacklotAPI::update(array('hostedAt' => 'http://www.ooyala.com/backlot', 'embedCode' =>
'dhbjM6U-1s7YkieEwJRepTrYiPed8dPe'));


$metaAssign = OoyalaBacklotAPI::metadata(array('metaMode' => 'add', 'embedCode' => 'dhbjM6U-1s7YkieEwJRepTrYiPed8dPe',
'type' => 'drama'));

$metaSearch = OoyalaBacklotAPI::metadata(array('metaMode' => 'query', 'embedCode' =>
'dhbjM6U-1s7YkieEwJRepTrYiPed8dPe'));


$labelClear = OoyalaBacklotAPI::labels(array('mode' => 'clearLabels', 'embedCodes' =>
'A5bjM6ugPkLWOxmmXxgk6fjJ22Kn60dw'));

?>

Ruby

require "rubygems"

require "base64"
require "cgi"
require "digest/sha2"
require "open-uri"


module Ooyala
  module Backlot
    module API

      # You can find your Partner and Secret codes under the Developers
      # area of the Backlot Account tab
      OOYALA_PARTNER_CODE = "<Your Partner Code>"
      OOYALA_SECRET_CODE = "<Your Secret Code>"

      def self.query(params)
        return send_request("query", params)
      end

      def self.query_thumbnails(params)
        return send_request("thumbnails", params)
      end

      def self.update(params)
        return send_request("edit", params)
      end

      def self.labels(params)
        return send_request("labels", params)
      end

      def self.metadata(params)
        return send_request("metadata", params)
      end

      private

      def self.send_request(request_type, params)

        # Add an expire time of 15 minutes unless otherwise specified
        params["expires"] ||= (Time.now.to_i + 10).to_s

        string_to_sign = OOYALA_SECRET_CODE
        url = "http://api.ooyala.com/partner/#{request_type}?pcode=#{OOYALA_PARTNER_CODE}"

        params.keys.sort.each do |key|
          string_to_sign += "#{key}=#{params[key]}"
          url += "&#{CGI.escape(key)}=#{CGI.escape(params[key])}"
        end

        digest = Digest::SHA256.digest(string_to_sign)
        signature = Base64::encode64(digest).chomp.gsub(/=+$/, '')

        url += "&signature=#{CGI.escape(signature)}"
        return open(url).readlines
      end
    end
  end
end


# A few examples:

liveContent = Ooyala::Backlot::API::query("status" => "live")

lifetimeStats = Ooyala::Backlot::API::query(
  "statistics" => "1d,2d,7d,28d,30d,31d,lifetime",
  "status" => "live")

allTrailers = Ooyala::Backlot::API::query("label[0]" => "trailers")

specificVideo = Ooyala::Backlot::API::query("embedCode" => "plajrfuW5PS5rgc-kuc9ZWtFtdnYpfiK")

thumbnails = Ooyala::Backlot::API::query_thumbnails(
  "embedCode" => "plajrfuW5PS5rgc-kuc9ZWtFtdnYpfiK",
  "range" => "0-99",
  "resolution" => "320x240")

titleAndPause = Ooyala::Backlot::API::update(
  "title" => "updated title",
  "status" => "paused",
  "embedCode" => "dhbjM6U-1s7YkieEwJRepTrYiPed8dPe");

hostedAt = Ooyala::Backlot::API::update(
  "hostedAt" => "http://www.ooyala.com/backlot",
  "embedCode" => "dhbjM6U-1s7YkieEwJRepTrYiPed8dPe");


metaAssign = Ooyala::Backlot::API::metadata(
  "metaMode" => "add",
  "embedCode" => "dhbjM6U-1s7YkieEwJRepTrYiPed8dPe",
  "type" => "drama");

metaSearch = Ooyala::Backlot::API::metadata(
  "metaMode" => "query",
  "embedCode" => "dhbjM6U-1s7YkieEwJRepTrYiPed8dPe");


labelClear = Ooyala::Backlot::API::labels(
  "mode" => "clearLabels",
  "embedCodes" => "A5bjM6ugPkLWOxmmXxgk6fjJ22Kn60dw");