Advertisement
EddieKidiw

Grab channel youtube api v3

Aug 21st, 2017
883
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.53 KB | None | 0 0
  1. <?php
  2. include 'includes/info.php';
  3. include 'functions/youtube-func.php';
  4. $channelId = $_GET['id']; //Channel Id(Don't Remove This)
  5. $url = ngegrab('https://www.googleapis.com/youtube/v3/channels?part=snippet,statistics,brandingSettings&id='.$channelId.'&key='.$apikey.'');
  6. $json = json_decode($url);
  7. if($json)
  8. {
  9. foreach ($json->items as $data)
  10. {
  11. $channelTitle = $data->snippet->title;
  12. $description = $data->snippet->description;
  13. $total = $data->statistics->videoCount;
  14. }
  15. $title = ''.$channelTitle.'';
  16. $ogtitle = ''.$channelTitle.' Channel';
  17. $ogdescription = ''.$description.'';
  18. include 'includes/head.php';
  19. echo '<div class="header"><i class="fa fa-television"></i> '.$channelTitle.' ('.$total.')</div>';
  20. }
  21. if(strlen($_GET['page']) >1)
  22. {
  23. $yesPage=$_GET['page'];
  24. }
  25. else
  26. {
  27. $yesPage='';
  28. }
  29. $grab = ngegrab('https://www.googleapis.com/youtube/v3/search?part=snippet&channelId='.$channelId.'&key='.$apikey.'&maxResults=10&type=video&pageToken='.$yesPage.'');
  30. $json = json_decode($grab);
  31. $nextpage=$json->nextPageToken;
  32. $prevpage=$json->prevPageToken;
  33. if($json)
  34. {
  35. foreach ($json->items as $hasil)
  36. {
  37. $id    = $hasil->id->videoId;
  38. $title = $hasil->snippet->title;
  39. $thumbnail = $hasil->snippet->thumbnails->medium->url;
  40. $hasil   = ngegrab('https://www.googleapis.com/youtube/v3/videos?key='.$apikey.'&part=snippet,contentDetails,statistics,topicDetails&id='.$id.'');
  41. $ks      = json_decode($hasil);
  42. foreach ($ks->items as $data)
  43. {
  44. $channelTitle = $data->snippet->channelTitle;
  45. $channelId = $data->snippet->channelId;
  46. echo '<div class="videos_list">';
  47. echo '<a href="/dl/'.$id.'/'.cleaned($title).'.html" rel="dofollow" title="'.$title.'">';
  48. echo '<table>';
  49. echo '<tbody>';
  50. echo '<tr valign="middle">';
  51. echo '<td>';
  52. echo '<img src="'.$thumbnail.'" class="img" alt="'.$title.'" title="'.$title.'>';
  53. echo '</td>';
  54. echo '<td style="padding-left:2px;">';
  55. echo '<div style="padding-bottom:1px;">';
  56. echo $title;
  57. echo '</div>';
  58. echo '<span style="color:blue">by</span> <span style="color:green">'.$channelTitle.'</span>';
  59. echo '</td>';
  60. echo '</tr>';
  61. echo '</tbody>';
  62. echo '</table>';
  63. echo '</a>';
  64. echo '</div>';
  65. }
  66. }
  67. echo '<div class="pagenavi" style="text-align:center">';
  68. if($_GET['id'])
  69. {
  70. if (strlen($prevpage)>1)
  71. {
  72. echo '<a href="/channel/'.$channelId.'/page/'.$prevpage.'" class="page_item" rel="dofollow" title="Prev">Prev</a>';
  73. }
  74. if (strlen($nextpage)>1)
  75. {
  76. echo '<a href="/channel/'.$channelId.'/page/'.$nextpage.'" class="page_item" rel="dofollow" title="Next">Next</a>';
  77. }
  78. }
  79. echo '</div>';
  80. }
  81. include 'includes/foot.php';
  82. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement