SFP Network

SFP Network Plus

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:
sfpnetwork.org/film.php?v=6307343

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.

deKO.LT

deKO.LT Plus

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.
Thanks.

Brad Dougherty

Brad Dougherty Staff

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

$curl = curl_init('vimeo.com/api/v2/video/6549503.json';);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$return = curl_exec($curl);
curl_close($curl);

$video = json_decode($return);
echo $video[0]->stats_number_of_plays;

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);
curl_close($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.

Forums

Forum Rules

  1. Be nice

    Even if you disagree with someone, keep it civil.

  2. Stay on topic

    If it’s not relevant, leave it out or start a new thread.

  3. Don’t Spam

    Re-re-re-re-posts drive us crazy.

  4. Respect the Staff

    We were members once, just like you.

+ Learn more

Our Support Team

  • Mark Mark
  • Ian Ian
  • Tommy Tommy
  • Darnell Darnell
  • Zena Zena
  • Rebecca Rebecca

We’re here to help 10am–6pm Eastern, Monday–Friday.