Simple Vimeo JSON API Implementation


/ Published in: PHP
Save to your folder(s)

This is a very simple use of the Vimeo API. All it does is list the video title, a thumbnail of the video, and the description. More advance script coming later.


Copy this code and paste it in your HTML
  1. <?php
  2. // make sure to replace vimeouser with your vimeo username
  3. $vimeorequest = 'http://vimeo.com/api/v2/vimeouser/videos.json';
  4. $vimeoci = curl_init($vimeorequest);
  5. curl_setopt($vimeoci,CURLOPT_RETURNTRANSFER, TRUE);
  6. $jsondoc = curl_exec($vimeoci);
  7. curl_close($vimeoci);
  8.  
  9. // parameter 'true' is necessary for output as PHP array
  10. $video = json_decode($jsondoc,true);
  11.  
  12. // the number of videos we want to display
  13. $videosToShow = 5;
  14.  
  15. for($i=0;$i<=$videosToShow;$i++){
  16. echo "<p><a href=\"" . $video[$i]['url'] . "\">" . $video[$i]['title'] . "</a></p>";
  17. echo "<p><a href=\"" . $video[$i]['url'] . "\"><img src=\"" . $video[$i]['thumbnail_medium'] . "\" alt=\"" . $video[$i]['title'] . "\" /></a></p>";
  18. echo "<p>" . $video[$i]['description'] . "</p>";
  19. echo "<hr />\n";
  20. }
  21. ?>

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.