How to upload a video with dailymotion data api using php

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.

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 (

create-dailymotion-api-keyWrite 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’;

$api = new Dailymotion();
$videotitle = “Title of the video”;
$videofile = “Actual path of the video”;
$videocategory = “Category of the video”;
$videotags = “Tags of the video”;
$videodescription = “Description of the video”;

$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’];