Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Youtube Subscribers, Total Views, Total Likes and Total Dislikes Counter #1

Open
delidolu1adam opened this issue Feb 3, 2022 · 0 comments

Comments

@delidolu1adam
Copy link

delidolu1adam commented Feb 3, 2022

Can we pull other data besides the youtube subscriber counter?

For example:

Subscribers:
Total Video:
Total Views:
Total Likes:
Total Dislikes:
Total Comment:

Thanks for this.

I did some research, tried something based on some examples but some of them are not working.

Source: https://stackoverflow.com/questions/25826571/get-comment-or-likes-count-for-youtube-video-using-api-3-0

<?php

// PHP - SUBSCRIBER COUNT USING YOUTUBE API V3
// BY @danielsebesta

// Google Developers: https://console.developers.google.com/apis/?pli=1
// Youtube Channel ID: https://www.youtube.com/account_advanced

$api_key = "AIzaSyBc-UkCwebflDh1pi0rNL7QTP-1Skf8TnU";
$channel_id = "UCfUwyi5dAZ3DuXI8GP9vhUg";

$api_response = file_get_contents('https://www.googleapis.com/youtube/v3/channels?part=statistics&id=' . $channel_id . '&key=' . $api_key . '');

$api_response_decoded = json_decode($api_response, true);

// Subscribers
$subscribers = $api_response_decoded['items'][0]['statistics']['subscriberCount'];

// Videos
$videos = $api_response_decoded['items'][0]['statistics']['videoCount'];

// Views
$views = $api_response_decoded['items'][0]['statistics']['viewCount'];

// Likes
$likes = $api_response_decoded['items'][0]['statistics']['likeCount'];

// Dislikes
$dislikes = $api_response_decoded['items'][0]['statistics']['dislikeCount'];

// Dislikes
$comments = $api_response_decoded['items'][0]['statistics']['commentCount'];


echo $subscribers;
echo "</br></br>";
echo $views;
echo "</br></br>";
echo $likes;
echo "</br></br>";
echo $dislikes;
echo "</br></br>";
echo $comments;
echo "</br></br>";
echo $videos;

?>


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant