Code Monkey home page Code Monkey logo

youtube-subscribers's Introduction

๐ŸŽฌ Youtube Subscriber Count using API

How to setup this script?

It's very simple.

$api_key = "";
$channel_id = "";

Just fill in these two fields and the code will work.

How to get API key?

Visit https://console.cloud.google.com and log in with your Google account, create the new project. Go to your created project and in the sidebar on the left, expand APIs & auth. Next, click APIs. In the list of APIs go to YouTube Data API (v3) and make sure that it's enabled (Enable API). On the sidebar click Credentials. Then click on Create New Key and choose Browser key. You can also watch tutorial for that:
Video tutorial

How to get Channel ID?

You need to visit the channel you want to display.

If the channel ID doesn't show up, just click on one of the videos on that channel and click on the channel icon.

youtube-subscribers's People

Contributors

danielsebesta avatar

Stargazers

 avatar

Watchers

 avatar

youtube-subscribers's Issues

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

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;

?>


Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.