Created
January 3, 2014 17:59
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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 | |
) | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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