How to upload a video with dailymotion data api using php

Hướng dẫn kiếm tiền online với Dailymotion từ A-Z

Dailymotion is one of the popular video sharing web sites. Users can share and watch videos from this website. There is an opportunity for users to share and earn revenue from their videos like YouTube. Users can upload videos either using the website and with the dailymotion php api. Uploading videos from the website is fairly easy but you can not schedule an upload task with it. In this article we will show you how to upload a video with dailymotion data api using php.

dailymotion logo

Creating Dailymotion DATA API credentials

In order to use dailymotion data api you need to have an authorisation to the website. This authorization consist of an apikey, apisecret, username and password. You need to create an apikey and apisecret from dailymotion developer console (

Write your channel name into application name box, write a description into application description, write a website address into Application Website box (generally this website address is used for embedding a video player into a website but you can enter your development servers website address into this box), write a purpose into Application Purpose box, if you need a dynamic callback url you can define it in the Callback URL box and lastly you can upload your custom application icon by using this form. After filling out this form in developer settings page you will have an api key and api secret. You will later use these credential in a php script file.

Dailymotion PHP SDK

There are PHP, JavaScript, Objective-C, Python and Android SDKs and their links to the related files in the dailymotion developer tools page ( The latest version of Dailymotion PHP SDK can be downloaded from  GitHub ( You don’t need to edit this PHP file to use the API, just link this file into your video uploader php script file by php require once command.

require_once 'Dailymotion.php';

Dailymotion video uploader php script file

The last part of the process is creating a video uploader php script file. In this file you will write your Dailymotion DATA API Credentials and details of the video. You can use below php script example while creating your file.

require_once 'sdk/Dailymotion.php';

// Dailymotion DATA API credentials
$apikey = 'Your API Key'; 
$apisecret = 'Your API Secret'; 
$user = 'Your user email address'; 
$password = 'Password';

$videotitle = "Title of the video"; 
//$videofile = "Actual path of the video";
$name = $_FILES["upload_file"]["name"];
move_uploaded_file($_FILES["upload_file"]["tmp_name"], "videos/".$name);
$videofile = "videos/".$name;
$videocategory = "Category of the video";
$videotags = "Tags of the video";
$videodescription = "Description of the video";
$api = new Dailymotion();
$api->setGrantType(Dailymotion::GRANT_TYPE_PASSWORD, $apikey, $apisecret, array('write','delete'), array('username' => $user, 'password' => $password)); 
$url = $api->uploadFile($videofile); 
$result = $api->call('video.create', array('url' => $url, 'title' => $videotitle , 'channel' => $videocategory , 'tags' => $videotags, 'description' => $videodescription, 'published' => true)); 
$videourl = ''.$result['id'];

if($result) {
 ?><a href="<?php echo $videourl; ?>" target="_blank">Click Here </a> <?php echo "click here to see this video."; 
 echo "Video uploaded successfully on";

You can edit this file to create a database connection or insert additional php features if you don’t want to enter all the video details every time.

Notify of
2 Bình luận
Cũ nhất
Mới nhất Most Voted
Inline Feedbacks
View all comments

Làm thế nào để dùng API upload video vào từng kênh riêng biệt khi mình đã trở thành MCN

Would love your thoughts, please comment.x