Advertisement
SecretWorker

Untitled

Jun 11th, 2015
215
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.28 KB | None | 0 0
  1. function getResults($query, $max, $p){
  2.         $ch = @curl_init("http://gdata.youtube.com/feeds/api/videos?v=2&format=5&alt=jsonc&max-results=".$max."&start-index=".$p."&q=" .urlencode($query));
  3.         @curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  4.         @curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.64 Safari/537.11");
  5.         $content = @curl_exec($ch);
  6.         @curl_close($ch);
  7.         $content = @json_decode($content);
  8.         $items = (array) $content->{'data'}->{'items'};
  9.         $names = array();
  10.         foreach($items as $item) {
  11.             $item = (array) $item;
  12.             $names[$item['id']] = $item['title'];
  13.         }
  14.         return $names;
  15.     }
  16.  
  17.     function getTotalResults($query) {
  18.         $ch = @curl_init("http://gdata.youtube.com/feeds/api/videos?v=2&format=5&alt=jsonc&q=" .urlencode($query));
  19.         @curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  20.         @curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.64 Safari/537.11");
  21.         $content = curl_exec($ch);
  22.         @curl_close($ch);
  23.         $content = @json_decode($content);
  24.         $items = (array) $content->{'data'}->{'items'};
  25.         $names = array();
  26.         foreach($items as $item) {
  27.             $item = (array) $item;
  28.             $names[$item['id']] = $item['title'];
  29.         }
  30.         return $names;
  31.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement