The following code works for Vimeo API:
function getTitle($id){
$title = unserialize(file_get_contents("http://vimeo.com/api/v2/video/$id.php"));
$theTitle=$title[0]['title'];
echo $theTitle;
}
If for Dailymotion I use:
$id2 = 'xks75n';
function dailyMotionTitle($id2){
$dm = unserialize(file_get_contents("http://www.dailymotion.com/embed/video/".$id2));
echo $dm[0]['title'];
}
I get Error at offset 0 of 1374 bytes. I know I can use embed.ly or JSON parsing but I prefer PHP. Any help concerning repair of Dailymotion PHP parsing is appreciated.
You can’t just change URLs and expect this to work.
Read through the Dailymotion APIs documentation pages to learn how to access video information programatically.
As one example, using the REST API, to get the title of your video in a JSON formatted response, fetch:
Which returns
Another option is to use the oEmbed API on the URL you have in the question.
Which returns
Hint: you can use
json_decode()to “decode” that into a PHP object or array to access the value(s).