无法使用 dailymotion api 获取私有视频的 iframe 代码
Unable to get the iframe code for a private video with dailymotion api
我需要用 'dailymotion-sdk-php' 嵌入一个私人的 dailymotion 视频。我创建了一个帐户并添加了一个密钥和秘密。但在 iframe 中我只收到 'Private content' 消息。
这是我的代码,
<?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>';
}
?>
如果有人能帮我存档就太好了
如果您有私人视频,并且想将其嵌入您的网站,则需要使用其私人 ID。 API 将 return 你这个 ID,在 private_id
字段下(你需要被验证为视频的所有者)。
此外,您可以使用 embed_url
直接获取嵌入 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!
我需要用 'dailymotion-sdk-php' 嵌入一个私人的 dailymotion 视频。我创建了一个帐户并添加了一个密钥和秘密。但在 iframe 中我只收到 'Private content' 消息。
这是我的代码,
<?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>';
}
?>
如果有人能帮我存档就太好了
如果您有私人视频,并且想将其嵌入您的网站,则需要使用其私人 ID。 API 将 return 你这个 ID,在 private_id
字段下(你需要被验证为视频的所有者)。
此外,您可以使用 embed_url
直接获取嵌入 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!