我想使用 dailymotion api 来获取我自己的私人视频的信息。所以...我有一个 Dailymotion 帐户我创建了一个 API 密钥和密钥我下载了 PHP 类我想获取我的私人视频的信息以在我的网站上显示它...
所以我想我需要验证我的帐户并在获取代码后......但它不起作用:'(请你给我一个示例代码来做到这一点吗?
我的测试代码现在就是这样
<?php
error_reporting(E_ALL & ~E_NOTICE);
ini_set('display_errors', 1);
$apiKey = 'xxxx';
$apiSecret = 'xxxx';
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/privateVideoId',
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>';
}
?>
结果是:不允许该用户访问该视频。
所以我认为身份验证存在问题......但我不明白如何仅使用 php 来做到这一点
非常感谢你的帮助