Jimmy Ruska's Blog
Php TutorialsCache Slow Pages for Performance
Youtube subscription Checker
Resizing images in PHP
Zip a File with PHP
Getting next auto_increment value from Mysql
Install PHP, MySQL, Apache the Bullet Proof Way
Benchmark your PHP with 3 lines of code
See all 7 posts
Php Tutorials RSS

Categoriesvideo tutorials (123)
funny pictures (30)
amazing pictures (11)
amazing videos (8)
php tutorials (7)
computer tricks (7)
hilarious videos (6)
personal updates (3)
youtube tips (3)
misc (3)
apache (2)
fake news (2)
articles (2)
cat videos (1)
My WebsitesBest of Internet
Streaming Anime Episodes
Free Video Tutorials
Best of Youtube
Electronics Discounts
MP3s From Google
Free Online Education
Funny Pictures Blog
Video Game Sheet Music
Free Movies Online
Online Degrees
College Online
Feb 14 | Youtube subscription Checker Posted on Thursday, February 14 2008 |
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.
$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(
"http://www.youtube.com/profile_subscriptions?user=$yname&page=$counter");
// check if you're in it
if (ereg("/$username",$contents)){
// if so, say yes and stop looping through pages
echo "is subscriber";
break;
}
}
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.
for($counter=1; $counter < 5; $counter++){
$contents = file_get_contents(
"http://www.youtube.com/profile_subscriptions?user=$person&page=$counter");
if (ereg("/jimmyrcom",$contents)) return true;
}
return false;
}
Then you can just say...
...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

Share:
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.