【发布时间】: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