【问题标题】:Unable to get the iframe code for a private video with dailymotion api无法使用 dailymotion api 获取私有视频的 iframe 代码
【发布时间】:2016-07-05 16:58:10
【问题描述】:

我需要使用“dailymotion-sdk-php”嵌入一个私人dailymotion 视频。我创建了一个帐户并添加了一个密钥和秘密。但在 iframe 中,我只收到“私人内容”消息。

这是我的代码,

<?php 
error_reporting(E_ALL & ~E_NOTICE);
ini_set('display_errors', 1);
set_time_limit(0);

$apiKey = 'my key';
$apiSecret = 'my secret';
require_once 'Dailymotion.php';
// Instanciate the PHP SDK.
$api = new Dailymotion();

// Tell the SDK what kind of authentication you'd like to use.
// Because the SDK works with lazy authentication, no request is performed at this point.
$api->setGrantType(Dailymotion::GRANT_TYPE_AUTHORIZATION, $apiKey, $apiSecret);

// $api = new Dailymotion();
try
{
$result = $api->get(
'/video/my id',
array('fields' => array('id', 'title', 'owner'))
);

}
catch (DailymotionAuthRequiredException $e)
{
echo $e->getMessage();
// If the SDK doesn't have any access token stored in memory, it tries to
// redirect the user to the Dailymotion authorization page for authentication.
return header('Location: ' . $api->getAuthorizationUrl());
}
catch (DailymotionAuthRefusedException $e)
{
echo $e->getMessage();
// Handle the situation when the user refused to authorize and came back here.
// <YOUR CODE>
}

trace($result);

function trace($d) {
echo '<pre>';
var_dump($d);
echo '</pre>';

echo '<iframe frameborder="0" width="480" height="270" src="http://www.dailymotion.com/embed/video/my id"></iframe>';
}
?>

如果有人能帮我存档就好了

【问题讨论】:

    标签: php dailymotion-api


    【解决方案1】:

    如果您有私人视频,并且想要将其嵌入您的网站,则需要使用其私人 ID。 API 将在 private_id 字段下向您返回此 ID(您需要验证为视频的所有者)。 此外,您可以使用embed_url 直接获取嵌入网址,或者您甚至可以获取embed_html。

    您可以使用的 API 调用示例: https://api.dailymotion.com/video/ID?fields=embed_html,embed_url,private,private_id&access_token=TOKEN

    在https://developer.dailymotion.com/api/faq#difference-private-public-videos获取更多关于私人视频的信息

    注意:当您嵌入私人视频时,您会披露其私人 ID。请注意,视频不再是完全私密的,因为任何人都可以获得此 ID!

    【讨论】:

    • 知道了。如果您可以使用令牌进行验证,那就太好了。那么它会更安全。
    猜你喜欢
    • 2021-01-28
    • 2021-09-14
    • 1970-01-01
    • 2014-09-27
    • 1970-01-01
    • 1970-01-01
    • 2015-08-21
    • 2015-07-30
    • 2014-08-15
    相关资源
    最近更新 更多