How to programmatically upload videos via Dailymotion’s API using our PHP SDK
Using our SDKs is the fastest and easiest way to programmatically upload videos on Dailymotion.
Follow this PHP tutorial to learn how to add a video on our servers and link it to your channel.
To upload videos on your Dailymotion channel using our PHP SDK, you need to:
Step 1: Authentication on Dailymotion via our API
You need to authenticate yourself through the API to gain access to the Dailymotion account on which the video will be uploaded.
Uploading videos requires the
#!/usr/bin/env php <?php require_once 'Dailymotion.php'; // Account settings - Replace the <credentials> below with your own $apiKey = '<yourApiKey>'; $apiSecret = '<yourApiSecret>'; $testUser = '<someUser>'; $testPassword = '<yourPassword>'; // Scopes you need to run your tests $scopes = array( 'manage_videos', ); // Dailymotion object instantiation $api = new Dailymotion(); $api->setGrantType( Dailymotion::GRANT_TYPE_PASSWORD, $apiKey, $apiSecret, $scopes, array( 'username' => $testUser, 'password' => $testPassword, ) );
See our authentication guide for more details
Step 2: Upload a video on Dailymotion with our PHP SDK
The PHP SDK implements Dailymotion’s API and allows you to upload videos on our platform in 2 steps (upload/creation).
is_created_for_kids fields are mandatory to publish a video.
// 1. Upload your file on Dailymotion's servers // Replace with the path to your video $url = $api->uploadFile('/path/to/your/video.mp4'); // 2. Create the video on your channel - Replace with your <CHANNEL_ID> $api->post( '/user/<CHANNEL_ID>/videos', array( 'url' => $url, 'title' => 'Dailymotion PHP SDK upload test', 'channel' => 'videogames', 'published' => true, 'is_created_for_kids' => false, ) );
'published' => false if you don’t want to publish the video immediately. It will be saved as a draft.
Not coding in PHP?
Visit Dailymotion’s SDKs documentation and find your own language!