Introduction

This set of tutorials is intented to help you make the most of dailymotion content, using our APIs. It will guide you through a series of working use-cases and help you quickstart your projects.

Prerequisites

  • Even if not mandatory, it is highly recommended that you use a Dailymotion SDKs for all calls when available. All examples also assume that you already instanciated the SDK and authenticated yourself.
  • Keep your SDK up to date regularly, by checking new releases. If case you're using our JavaScript SDK, embed it directly from our CDN.
  • You should also take care or try-catching most of your API calls in case of unforeseen errors. Please refer to the Data API overview for more information on errors.

Note for cURL users: All of these examples assume that you are using the cURL library under a Unix-like environment. It should work approximately the same way using wget or plain sockets, please refer to the manual of your tool of choice. All examples also assume that you already authenticated yourself and obtained an access token in the ${ACCESS_TOKEN} shell variable.


Testing environment for PHP

Here you can find an example of how to test API actions using simple use-cases.

First, create a local_config.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,
    $scopes,
    array(
        'username' => $testUser,
        'password' => $testPassword,
    )
);

Then, include this local_config.php in your test case script:

require_once 'local_config.php';

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

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