我刚上传视频后,我正在尝试使用 API 检索“thumbnail_url”。但是,我检索到的“thumbnail_url”始终是这个 URL “Hhttp://s2.dmcdn.net/KtV-L.jpg”或“Hhttp://s2.dmcdn.net/KtV-L/x240-gK0.jpg” (当我使用 oEmbed API 时)。
另一方面,当我像以下 URL 一样手动将 URL 放入浏览器的地址栏中时,我可以获得我想要的“thumbnail_url”。Hhttps://api.dailymotion.com/video/VIDEOID?fields=thumbnail_url
我的问题是;上传视频后是否存在时间延迟或 Dailymotion API 是否需要更多时间来生成缩略图?或者,检索我编码的缩略图网址的方法是否错误?
这是获取缩略图图像 url 的代码。*作为先决条件,我已经获得了访问令牌,创建了一个视频并发布了。
/////////////// Publish a video ///////////////
$publishVideoAPI = "https://api.dailymotion.com/video/".$responseID;
// Post data
$dataPublish = array(
"title" => $videotitle,
"published" => true,
"channel" => "shortfilms",
"tags" => $tags,
"access_token" => $accesstoken
);
$conn = curl_init();
// Post method
curl_setopt($conn, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($conn, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($conn, CURLOPT_RETURNTRANSFER, true);
curl_setopt($conn, CURLOPT_URL, $publishVideoAPI);
curl_setopt($conn, CURLOPT_POST, true);
curl_setopt($conn, CURLOPT_POSTFIELDS, $dataPublish);
// execute
$resPublish = curl_exec($conn);
echo "publish video<br />";
var_dump($resPublish);
// close
curl_close($conn);
/////////////// Grab a thumbnail image of the video start ///////////////
// API
$thumbnail = "https://api.dailymotion.com/video/".$responseID."?fields=thumbnail_url";
// initialise session
$conn = curl_init();
// Get method
curl_setopt($conn, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($conn, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($conn, CURLOPT_RETURNTRANSFER, true);
curl_setopt($conn, CURLOPT_HEADER, false);
curl_setopt($conn, CURLOPT_URL, $thumbnail);
// execute
$res2 = curl_exec($conn);
echo "thumbnail url<br />";
//var_dump($res2);
echo "<br /><br />";
// close
curl_close($conn);
$thumbnailData = json_decode( $res2 , true );
$thumbnailURL = $thumbnailData["thumbnail_url"];
echo $thumbnailURL;