Skip to content

Instantly share code, notes, and snippets.

@dailymotion-api
Created January 3, 2014 17:59
Show Gist options
  • Save dailymotion-api/8242887 to your computer and use it in GitHub Desktop.
Save dailymotion-api/8242887 to your computer and use it in GitHub Desktop.
PHP testing environment Here you can find an example of how to test API actions using simple use-cases
<?php
require_once 'Dailymotion.php';
// ----- account settings -----//
$apiKey = 'yourApiKey';
$apiSecret = 'yourApiSecret';
$testUser = 'someUser';
$testPassword = 'yourPassword';
$videoTestFile = '/path/to/video/test.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,
array(implode(',', $scopes)),
array(
'username' => $testUser,
'password' => $testPassword
)
);
<?php
require_once 'config.php';
$url = $api->uploadFile($testVideoFile);
$result = $api->post(
'/videos',
array('url' => $url,
'title' => 'PHP SDK test upload',
'published' => true,
'channel' => 'videogames')
);
var_dump($result);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment