1

i'm try to write dailymotion api upload php code i'm use example code from https://developer.dailymotion.com/guides it's work great

and i want add Geoblocking only allow Japan this is my code

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);

but i got this error

Fatal error: Uncaught exception 'DailymotionAuthRequiredException' with message 'Insufficient rights for the `geoblocking' parameter of route `POST /videos'. Required scopes: manage_videos'

anyone can tell me what i'm doing wrong and help me fix this problem thank you

1 Answers1

1

'geoblocking' => 'JP' change to 'geoblocking' => 'jp'

your code will be

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);
Dai Tran
  • 86
  • 6