dscdttg4389 2014-11-19 11:11
浏览 62
已采纳

DailyMotion Cloud API如何获得具有referer严格安全性的URL?

I'm stuck with the DailyMotionCloud API I need to sign a URL with security levels on it

  1. geo-blocking allowing only: France
  2. referer strict allowing only: 1 Domain (oxygenstream.fr)

My code works but I don't know where to put the security levels when signing my URL I'm supposed to put it in the component [-<pub-sec-data>] here: https://www.dmcloud.net/doc/api/api-streaming.html#signing-a-url

How am I supposed to store de referer strict URL and the Country in the [-<pub-sec-data>]?

Here is the code of the CloudKey.php: https://github.com/dailymotion/cloudkey-php/blob/master/CloudKey.php

Here is my code:

<iframe src="<?php 
require_once 'CloudKey.php';

$user_id = 'aaaaaaaaaaaaaaaaaaaaaa'; 
$api_key = 'bbbbbbbbbbbbbbbbbbbbbb'; 
$media_id = '5466232b947399290102cdb6';
$preset_id = '54662c7c06361d307810e3b5'; // player preset 
$preset_name = 'OxygenStream'; // preset name

$seclevel = 32800 ; // I need 2 security levels (country & referer strict)
//          32800 = 1 << 5 . 1 << 15 or CLOUDKEY_SECLEVEL_COUNTRY . CLOUDKEY_SECLEVEL_REFERER_STRICT
$countries = 'cc=fr'; // I'm supposed to put it in the [-<pub-sec-data>] 
$referers = 'rf=http://www.oxygenstream.fr/vod/dmcloud';; // I'm supposed to put it in the [-<pub-sec-data>]

// We create the url 
$url = sprintf('https://api.dmcloud.net/player/embed/%s/%s/';, $user_id, $media_id);

// We sign the url 
$url = CloudKey_Helpers::sign_url($url, $api_key, $seclevel, null, null, null, $countries, $referers, null);

// We write the URL in the Iframe 
print($url . '&autoplay=1&preset=54662c7c06361d307810e3b5');?>" width="640" height="360" frameborder="0" allowfullscreen></iframe>

Thanks in advance for helping me with this.
Hope you know how to fix my code.

I wish you a great day,

Antoine

  • 写回答

1条回答 默认 最新

  • douzi7890 2014-11-19 12:37
    关注

    Since you are using the CloudKey PHP SDK you should really not have to build the URL yourself.

    When using the SDK, this works for me:

    $user_id = 'aaaaaaaaaaaaaaaaaaaaaa'; 
    $api_key = 'bbbbbbbbbbbbbbbbbbbbbb'; 
    $media_id = '5466232b947399290102cdb6';
    $preset_id = '54662c7c06361d307810e3b5';
    $preset_name = 'OxygenStream';
    
    $seclevel = CLOUDKEY_SECLEVEL_COUNTRY | CLOUDKEY_SECLEVEL_REFERER_STRICT ;
    $countries = array('fr');
    $referers = array('http://oxygenstream.fr/vod/dmcloud');
    
    $cloudkey = new CloudKey($user_id, $api_key);
    $url = $cloudkey->media->get_embed_url(array('id' => $media_id, 'seclevel' => $seclevel, 'expires' => time() + 3600, 'countries' => $countries, 'referers' => $referers));
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥30 关于用python写支付宝扫码付异步通知收不到的问题
  • ¥50 vue组件中无法正确接收并处理axios请求
  • ¥15 隐藏系统界面pdf的打印、下载按钮
  • ¥15 MATLAB联合adams仿真卡死如何解决(代码模型无问题)
  • ¥15 基于pso参数优化的LightGBM分类模型
  • ¥15 安装Paddleocr时报错无法解决
  • ¥15 python中transformers可以正常下载,但是没有办法使用pipeline
  • ¥50 分布式追踪trace异常问题
  • ¥15 人在外地出差,速帮一点点
  • ¥15 如何使用canvas在图片上进行如下的标注,以下代码不起作用,如何修改