SFP Network

SFP Network

I was wondering if there was a way, through php, of publishing the statistics from Vimeo onto my site where the embedded video is?

Here is the page:

Where it says views I'd like to use your total stats for that video instead of my page views counter. It just needs to print plain numbers, like 77.



Maybe can someone explain in easier way how to get that simple number?
Sorry, i'm not a good programmer, just need a little help.

Brad Dougherty

Brad Dougherty Staff

To get the stats on one of your videos in PHP, you could do this:

$curl = curlinit('vimeo.com/api/v2/video/6549503.json';); curlsetopt($curl, CURLOPTRETURNTRANSFER, 1); $return = curlexec($curl); curl_close($curl);

$video = jsondecode($return); echo $video[0]->statsnumberofplays;

Just replace "6549503" with the ID of the video you want to get.

La Lengua

La Lengua

$VIDEO_ID = [Your vimeo video id number]

//OPTION 1: CURL & json_decode
$curl = curl_init(' vimeo.com/api/v2/video/'.$VIDEO_ID.'.json';);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$return = curl_exec($curl);
$JSON_Data = json_decode($return);

$thumburl = $JSON_Data[0]->thumbnail_small;
$views = $JSON_Data[0]->stats_number_of_plays;
$upload_date = $JSON_Data[0]->upload_date;
$duration = $JSON_Data[0]->duration;

//OPTION 2: file_get_contents & json_decode
$JSON = @file_get_contents("http:// vimeo.com/api/v2/video/".$VIDEO_ID.'.json';);
$JSON_Data = @json_decode($JSON);

$thumburl = $JSON_Data[0]->thumbnail_small;
$views = $JSON_Data[0]->stats_number_of_plays;
$upload_date = $JSON_Data[0]->upload_date;
$duration = $JSON_Data[0]->duration;

//OPTION 3: unserialize & file_get_contents PHP
$hash = unserialize(@file_get_contents("http:// vimeo.com/api/v2/video/".$VIDEO_ID.".php";));

$thumburl = $hash[0]['thumbnail_small'];
$views = $hash[0]['stats_number_of_plays'];
$upload_date = $hash[0]['upload_date'];
$duration = $hash[0]['duration'];

This conversation is missing your voice. Please join Vimeo or log in.