Advertisement
_Error

Untitled

Aug 26th, 2016
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. function getStats($ID, $api)
  2. {
  3. $JSON = file_get_contents("https://www.googleapis.com/youtube/v3/videos?part=statistics&id=" . $ID . "&key=" . $api);
  4. $json_data = json_decode($JSON, true);
  5.  
  6. $jsonTitle = file_get_contents("https://www.googleapis.com/youtube/v3/videos?id=" . $ID ."&key=". $api . "&fields=items(snippet(title))&part=snippet");
  7. $jsonTitle_data = json_decode($jsonTitle, true);
  8.  
  9. $main = $json_data ['items'][0];
  10. $stats = $json_data['items'][0]['statistics'];
  11. $title = $jsonTitle_data['items'][0]['snippet'];
  12.  
  13. $arr = ARRAY(
  14. 'title' => $title['title'],
  15. 'id' => $main['id'],
  16. 'viewCount' => $stats['viewCount'],
  17. 'likeCount' => $stats['likeCount'],
  18. 'dislikeCount' => $stats['dislikeCount'],
  19. 'commentCount' => $stats['commentCount']
  20.  
  21. );
  22.  
  23. RETURN $arr;
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement