How to Get YouTube Channel Subscriber Count without Using API

YouTube provides these subscribe buttons which include the number of your channel subscribers which can be extracted using a simple regular expression.

Extract the Subscribe Count in PHP

<?php

// Change channelid value to match your YouTube channel ID
$url = 'https://www.youtube.com/subscribe_embed?channelid=UCopSjr1a2QgRvm-yJRqcPpA';

// Fetch the Subscribe button HTML
$button_html = file_get_contents( $url );

// Extract the subscriber count
$found_subscribers = preg_match( '/="0">(\d+)</i', $button_html, $matches );

if ( $found_subscribers && isset( $matches[1] ) ) {
    echo intval( $matches[1] );
}

The Channel ID can be found on your YouTube profile page.

Demo

Here is the number of subscribers of my YouTube channel.

Never lose a single business lead or enquiry again! Get my latest plugin Storage for Contact Form 7 now!

Buy now for only $19 →

Leave a Reply