Reputation: 1048
I am trying to upload video on dailymotion using graph API here:
http://www.dailymotion.com/doc/api/graph-api.html
Authenticated successfully with read and write permission but when trying to upload video using below api publishing method: http://www.dailymotion.com/doc/api/graph-api.html#publishing Getting Errors
stdClass Object ( [error] => stdClass Object ( [code] => 400 [message] => The `url' parameter returns an invalid content type: text/plain, must be video/* [type] => invalid_parameter ) )
I am posting request to API using below cURL:
$fields = '';
$data = array(
"access_token" => $token,
"url" => "https://www.somesite.com/demo/dailymotion/X.mp4"
);
$url = "https://api.dailymotion.com/me/videos";
foreach($data as $key => $value) {
$fields .= $key . '=' . $value . '&';
}
rtrim($fields, '&');
$post = curl_init();
curl_setopt($post, CURLOPT_URL, $url);
curl_setopt($post, CURLOPT_POST, count($data));
curl_setopt($post, CURLOPT_POSTFIELDS, $fields);
curl_setopt($post, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($post);
curl_close($post);
print_r(json_decode($result));
Some one please help me to fix this issue.
Upvotes: 1
Views: 2299
Reputation: 427
I think you have a problem with the url to your video, it looks like it's not recognized as a video:
invalid content type: text/plain, must be video/* [type]
You should use an upload url delivered through the api: perform an HTTP GET to /file/upload to get the upload URL and post your video to this address using multipart/form-data content-type with the video in the file field. When testing your code with this url, it worked.
I have two comments though: why don't you use the php sdk ? It will make everything a lot easier for you ! Also, in order for your video to be published, you should specify a title and a channel for it, and set "published" to true, in your data array:
$data = array(
"access_token" => $token,
"channel" => "news",
"title" => "my title",
"published"=> True,
"url" => $videourl
);
This is described at : http://www.dailymotion.com/doc/api/getting-started.html#publishing-videos and you can find a use case using php sdk at http://www.dailymotion.com/doc/api/use-cases.html
Upvotes: 1