Skip to content

Commit 5566613

Browse files
committed
Add YouTube view count example
1 parent 34742ee commit 5566613

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

examples/youtube_video_count.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
require '../src/Curl.class.php';
3+
4+
5+
$video_ids = array(
6+
'9bZkp7q19f0',
7+
'_OBlgSz8sSM',
8+
'uelHwf8o7_U',
9+
'KQ6zr6kCPj8',
10+
'ASO_zypdnsQ',
11+
'pRpeEdMmmQ0',
12+
);
13+
14+
foreach ($video_ids as $video_id) {
15+
$curl = new Curl();
16+
$curl->get('https://gdata.youtube.com/feeds/api/videos/' . $video_id . '?alt=json');
17+
echo '"' . $curl->response->entry->title->{'$t'} . '" has ' .
18+
number_format($curl->response->entry->{'yt$statistics'}->viewCount) . ' views.' . "\n";
19+
}

0 commit comments

Comments
 (0)