未捕获的每日运动身份验证需要异常



我正在尝试使用Dailymotion API。我遵循了所有可能的说明,但我不断收到错误,尽管我正在使用人们在其他帖子中建议的更改,即。每日运动 授权码无效

我遇到的错误

致命错误:未捕获的每日运动身份验证必需异常在/library/WebServer/Documents/basic/Dailymotion.php:582 堆栈跟踪:

0/library/WebServer/Documents/basic/Dailymotion.php(404(: Dailymotion->getAccessToken((

1/library/WebServer/Documents/basic/Dailymotion.php(356(: Dailymotion->call('GET/file/uploa...', Array(

2/library/WebServer/Documents/basic/Dailymotion.php(326(: Dailymotion->get('/file/upload', Array(

3/library/WebServer/Documents/basic/index.php(12(: 每日运动>上传文件(空(

4 {main} 扔在/Library/WebServer/Documents/basic/Dailymotion 中.php 在第 582 行

我的 php 中缺少某些内容吗?我还没有看到有人引用getAccessToken。

<?
include("Dailymotion.php");
$apiKey = "xxxxxxxxxxxxxxx";
$apiSecret = "xxxxxxxxxxxxxxxxxxxxxxxxxxx";
$user = "my username";
$pwd = "my password";
$filepath = "Test.mp4";
$api = new Dailymotion();
$api->setGrantType(Dailymotion::GRANT_TYPE_PASSWORD, $apiKey, $apiSecret, array('manage_videos', 'write','delete'), array('username' => $user, 'password' => $pwd));
$url = $api->uploadFile($filepath);
$result = $api->call('video.create', array(
'url' => $url,
'title' => $title,
'description' => $description,
'private' => 'false',
'published' => 'true',
));
?> 

找到了答案,我一直假设人们的答案就像原样。我没有意识到我必须把它放到另一个位来授权我的帐户。


require_once 'Dailymotion.php';
// Account settings
$apiKey        = 'your apikey';
$apiSecret     = 'your secret';
$testUser      = 'your username';
$testPassword  = 'your password';
// Scopes you need to run your tests
$scopes = array(
'manage_videos',
);
// Dailymotion object instanciation
$api = new Dailymotion();
$api->setGrantType(Dailymotion::GRANT_TYPE_AUTHORIZATION, $apiKey, $apiSecret);
try
{
// The following line will actually try to authenticate before making the API call.
// * The SDK takes care of retrying if the access token has expired.
// * The SDK takes care of storing the access token itself using its `readSession()`
//   and `storeSession()` methods that are made to be overridden in an extension
//   of the class if you want a different storage than provided by default.
$url = $api->uploadFile('Test.mp4');
$result = $api->call('video.create', array(
'url' => $url,
'title' => 'prove this works',
'description' => 'THis is purely a test',
'private' => 'false',
'published' => 'true'
));
var_dump($result);
}
catch (DailymotionAuthRequiredException $e)
{
// 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)
{
}
?>

最新更新