George George - 1 year ago 109
PHP Question

dailymotion API PHP question

The following code works for Vimeo API:

function getTitle($id){
$title = unserialize(file_get_contents("$id.php"));
echo $theTitle;

If for Dailymotion I use:

$id2 = 'xks75n';
function dailyMotionTitle($id2){
$dm = unserialize(file_get_contents("".$id2));
echo $dm[0]['title'];

I get Error at offset 0 of 1374 bytes. I know I can use or JSON parsing but I prefer PHP. Any help concerning repair of Dailymotion PHP parsing is appreciated.

Answer Source

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

    "title": "The Farmer and His Sons- Aesop's fables"

Another option is to use the oEmbed API on the URL you have in the question.

Which returns

    "type": "video",
    "version": "1.0",
    "provider_name": "Dailymotion",
    "provider_url": "http:\/\/",
    "title": "The Farmer and His Sons- Aesop's fables",
    "author_name": "hooplakidz",
    "author_url": "http:\/\/\/hooplakidz",
    "width": 480,
    "height": 269,
    "html": "<iframe src=\"http:\/\/\/embed\/video\/xks75n\" width=\"480\" height=\"269\" frameborder=\"0\"></iframe>",
    "thumbnail_url": "http:\/\/\/static\/video\/369\/709\/34907963:jpeg_preview_large.jpg?20110830044159",
    "thumbnail_width": 426.666669846,
    "thumbnail_height": 240

Hint: you can use json_decode() to "decode" that into a PHP object or array to access the value(s).

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download