使用Geoblocking上传Dailymotion API PHP

时间:2017-08-07 15:07:10

标签: dailymotion-api

我正在尝试编写dailymotion api上传php代码 我使用https://developer.dailymotion.com/guides中的示例代码 这很棒

我希望添加Geoblocking只允许日本 这是我的代码

require_once 'Dailymotion.php';

// Account settings
$apiKey        = 'xxxxxxxxxxxxxxxxxx';
$apiSecret     = 'xxxxxxxxxxxxxxxxxx';
$testUser      = 'xxxxxxxxxxxxxxxxxx@xxxx.com';
$testPassword  = 'xxxxxxxxxxxxxxxxxx';
$videoTestFile = 'C:/output.mp4';

// Scopes you need to run your tests
$scopes = array(
    'userinfo',
    'feed',
    'manage_videos',
);
// Dailymotion object instanciation
$api = new Dailymotion();
$api->setGrantType(
    Dailymotion::GRANT_TYPE_PASSWORD,
    $apiKey,
    $apiSecret,
    $scopes,
    array(
        'username' => $testUser,
        'password' => $testPassword,
    )
);

$url = $api->uploadFile($videoTestFile);

$result = $api->post(
    '/videos',
    array(
        'url'       => $url,
        'title'     => 'Dailymotion PHP SDK upload test 2',
        'tags'      => 'dailymotion,api,sdk,test',
        'channel'   => 'videogames',
        'published' => true,
        'geoblocking' => 'JP', // i'm add this line
    )
);
var_dump($result);

但是我收到了这个错误

Fatal error: Uncaught exception 'DailymotionAuthRequiredException' with message 'Insufficient rights for the `geoblocking' parameter of route `POST /videos'. Required scopes: manage_videos'
任何人都可以告诉我 我做错了什么,帮我解决这个问题 谢谢

1 个答案:

答案 0 :(得分:0)

'geoblocking'=> 'J.P' 更改为'geoblocking'=> “专利文献

您的代码将

require_once 'Dailymotion.php';

// Account settings
$apiKey        = 'xxxxxxxxxxxxxxxxxx';
$apiSecret     = 'xxxxxxxxxxxxxxxxxx';
$testUser      = 'xxxxxxxxxxxxxxxxxx@xxxx.com';
$testPassword  = 'xxxxxxxxxxxxxxxxxx';
$videoTestFile = 'C:/output.mp4';

// Scopes you need to run your tests
$scopes = array(
'userinfo',
'feed',
'manage_videos',
);
// Dailymotion object instanciation
$api = new Dailymotion();
$api->setGrantType(
Dailymotion::GRANT_TYPE_PASSWORD,
$apiKey,
$apiSecret,
$scopes,
array(
    'username' => $testUser,
    'password' => $testPassword,
)
);

$url = $api->uploadFile($videoTestFile);

$result = $api->post(
'/videos',
array(
    'url'       => $url,
    'title'     => 'Dailymotion PHP SDK upload test 2',
    'tags'      => 'dailymotion,api,sdk,test',
    'channel'   => 'videogames',
    'published' => true,
    'geoblocking' => 'jp' // NO , in last line
)
);
var_dump($result);