1

I'm using Google YouTube API Ver2 to get video data, everything works good but I got the same views number "12180171" for all videos !

$data=@file_get_contents('http://gdata.youtube.com/feeds/api/videos/'.$video_id.'?v=2&alt=jsonc');
$obj=json_decode($data);
$video_data['views'] = number_format($obj->data->viewCount, 0, ',', ',');

video_id example : -0_JiSm5_EA

user3003810
  • 941
  • 3
  • 18
  • 45

2 Answers2

0

I guess the video id you are using is the one included in the youtube url (for all visitors).

It seems it's not the video_id.

Check there to get the real video_id : Youtube API - Extract video ID

Community
  • 1
  • 1
zeflex
  • 1,487
  • 1
  • 14
  • 29
0

Actually I faced the same problem since yesterday, and I discovered that Google has stopped gdata API (ver 2.0), you can check the below link

http://youtube-eng.blogspot.com/2015/04/bye-bye-youtube-data-api-v2.html

you can check this post on Stackoverflow it's pretty useful, it doesn't solve the entire problem but still appreciated effort

Fetch video details on Youtube using API v3 in PHP

Community
  • 1
  • 1
Doaa Magdy
  • 518
  • 5
  • 20