I want to get list of private Dailymotion videos.
I am able to receive an access token with a private key. But then when I send Get request to retrieve the list of videos, I see the following “400 Bad Request: malformed Host header”.
<?php
//Perform authentication
// Specify the URL and data
$url = "https://partner.api.dailymotion.com/oauth/v1/token";
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$headers = array(
"Host: partner.api.dailymotion.com",
"Content-Type: application/x-www-form-urlencoded",
);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
$data = "grant_type=client_credentials&client_id=xxx&client_secret=xxx&scope=manage_videos";
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
$resp = curl_exec($curl);
curl_close($curl);
$data = json_decode($resp, true);
$access_token = $data['access_token'];
$url = "https://partner.api.dailymotion.com/user/userid/videos?fields=id&limit=30&private=true";
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$headers = array(
"Host: partner.api.dailymotion.com/rest",
);
$auth = "Authorization: Bearer " . $access_token;
$headers[1] = $auth;
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
$resp = curl_exec($curl);
curl_close($curl);
//var_dump($resp);
?>
When I omit host in headers I get 404 Not Found.
$headers = array(
);
$auth = "Authorization: Bearer " . $access_token;
$headers[0] = $auth;
I also tried to use the following url. I get 404 Not Found.
$url = "https://partner.api.dailymotion.com/videos?fields=id&private=true&owners=userid;