class-vimeo.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <?php
  2. /**
  3. * Vimeo
  4. *
  5. * with help of the API this class delivers all kind of Images/Videos from Vimeo
  6. *
  7. * @package socialstreams
  8. * @subpackage socialstreams/vimeo
  9. * @author ThemePunch <info@themepunch.com>
  10. */
  11. class TP_vimeo {
  12. /**
  13. * Stream Array
  14. *
  15. * @since 1.0.0
  16. * @access private
  17. * @var array $stream Stream Data Array
  18. */
  19. private $stream;
  20. /**
  21. * Get Vimeo User Videos
  22. *
  23. * @since 1.0.0
  24. */
  25. public function get_vimeo_videos($type,$value){
  26. //call the API and decode the response
  27. if($type=="user"){
  28. $url = "https://vimeo.com/api/v2/".$value."/videos.json";
  29. }
  30. else{
  31. $url = "https://vimeo.com/api/v2/".$type."/".$value."/videos.json";
  32. }
  33. $rsp = json_decode(file_get_contents($url));
  34. return $rsp;
  35. }
  36. /**
  37. * Prepare output array $stream for Vimeo videos
  38. *
  39. * @since 1.0.0
  40. * @param string $videos Vimeo Output Data
  41. */
  42. private function vimeo_output_array($videos,$count){
  43. foreach ($videos as $video) {
  44. if($count-- == 0) break;
  45. $stream = array();
  46. $image_url = @array(
  47. 'thumbnail_small' => array($video->thumbnail_small),
  48. 'thumbnail_medium' => array($video->thumbnail_medium),
  49. 'thumbnail_large' => array($video->thumbnail_large),
  50. );
  51. $stream['custom-image-url'] = $image_url; //image for entry
  52. $stream['custom-type'] = 'vimeo'; //image, vimeo, youtube, soundcloud, html
  53. $stream['custom-vimeo'] = $video->id;
  54. $stream['post_url'] = $video->url;
  55. $stream['post_link'] = $video->url;
  56. $stream['title'] = $video->title;
  57. $stream['content'] = $video->description;
  58. $stream['date_modified'] = $video->upload_date;
  59. $stream['author_name'] = $video->user_name;
  60. $this->stream[] = $stream;
  61. }
  62. }
  63. }
  64. ?>