Jimmy's Blog Jimmy Ruska's Blog
Youtube subscription Checker Posted on Thursday, February 14 2008
Learn to Play Songs by Ear: Ear Training

On my video tutorials page, I let people ask me questions, but the script checks if the person is subscribed to my videos first (spend a second helping me, I help you). The code for it is actually surprisingly short.

$pages=5; // how many pages to scan through
$username='jimmyrcom'; // my username
$yname='youtube username of user'; // their username

// loop through the pages
for($counter=1; $counter < $pages; $counter++){
// get their subscriptions page
$contents = file_get_contents(
// check if you're in it
if (ereg("/$username",$contents)){
// if so, say yes and stop looping through pages
echo "is subscriber";

It's not good to grab too many pages because the script takes too long to return. If the person has over 300 subscriptions chances are they're not going to be watching your videos anyway. Making it a function that returns true or false is a better idea than just having it break. Here's the code without all the comments or variables, it's 6 lines of code if you don't count the curly braces.

function checkifsubscriber($person){
for($counter=1; $counter < 5; $counter++){
$contents = file_get_contents(
if (ereg("/jimmyrcom",$contents)) return true;
return false;

Then you can just say...

if (checkifsubscriber('person')){
...commence awesome code
else echo "not subbed";

Even if they don't show their subscription list this code will still work. If you want to make a list of all your subscribers use the preg_match_all function at the end after you concatenate the contents of the loop.

Tags: php youtube, zend, youtube api, youtube subscription checker, youtube subscriber checker, subscriptions

stumble digg delicious

Blog by Jimmy Ruska
Add me: Youtube, Twitter, Facebook, MySpace


More OMFG-Good Links

See all Posts in the Funny Pictures category.
Download mp3s faster than limewire using google.
I've made 100+ free video tutorials.
See the best of the internet today on one page.