Simple YouTube API Class in PHP: Redeaux — Revision 2 (update)
Just a note: It’s not 100% done yet, still have a few minor tweaks. I’m going to be uploading the final version this Friday. I think there will be one more revision after this one, then we will launch the official first version. Thank you for all of your patient and feedback as we strive to make this the most popular PHP4/5 YouTube API on the internet.
A lot of you have read our post including our YouTube API. I know because it almost gets as much traffic as the post on how to hide everything on your myspace profile.
Now because of it’s popularity you guys have requested a lot of bug fixes and a new release — revision 2. On top of that a lot of you are still using PHP4, I have no idea why, but you are.
I decided to address every individual bug that you guys commented on the post, and address issues that I thought were relevant on top of your findings (which have been extremely helpful.)
This brings me to the NEW and IMPROVED YouTube API Class.
Here’s the current changelog
- Page numbers are inaccurate, and don’t allow you to go to the last page because of numbering issues
- This was caused by YouTube displaying x amount of videos per page, and us/you having a different number of results per page, for example compared to YouTube’s 20 results per page. So while there would be 3149 pages, there’s really not that many because you either have MORE videos per page than YouTube does, or you have way less, either way this has been fixed by dividing the total number of videos by the amount of videos you want per page.
- Spaces in search result in internal error because no URL encoding was present.
- You guys know the bug, you’d search for “big rocket” or “nice booty” and it would break because the space (%20 in url encoding) wasn’t getting encoded properly. This has been fixed.
There are more bugs that have been fixed, but those two were really most prominent in the sense that, they caused everything else to break.
Here’s the new feature list (these are supplemental features, none of the old functionality is gone, these are just added to it.)
- Support for PHP4 (yes, that’s right.)
- Support for curl_init() instead of the user of file_get_contents() (disabled on some shared hosts.)
- Support for searching by video title (instead of tag.)
- Support for retrieving video by id
- Support for “method scaffolding” you can pass multiple things like video_id=this&tag=this&search=this, etc. It will return supplemental results.
- Support for “naked display” displaying videos in a style-less layout so you can style it on your own.
- Support for manual methoding. Use the manual_method() to write your own custom call and return the results, or errors, formatted inside of the HTML.
- Support for “embed_only()” display. So you can create scripts to embed videos.
All of the support is in ONE class file. You don’t download a separate version if you’re using PHP4, or PHP5, it’s all the same thing and it detects it by itself.
…and a lot more.
I will be writing a full blown tutorial on how to get the most out of the YouTube API class on Friday so you guys can get to work, along with a zip and a rar.
I have an idea to allow you to get updates for it dynamically from WaxJelly’s dev server (sort of like a remote SVN.) but through PHP directly. Let me know what you think about that, in other words, you don’t have to patch it, we do it for you and you just turn the boolean on or off. It’s an idea, and a good one I think.
ALSO! We’re going to be putting this thing on DIGG FRIDAY! You guys better help us out and return some love by digging it (if you digg it, of course.) we’re not forcing anybody here, but the more people we get using it the better it’s going to get.
I’m also willing to accept your code and give you credit for it, so I’ll have more info on that this friday.
If you have any ideas boys, post them now, you’ve got 5 days and then I’m releasing this it. Let me know what you think.
You may Leave a comment or Subscribe to Comments RSS or Trackback this entry.
59 comments so far
Leave a comment
Please be polite and on topic. Your e-mail will never be published.
Me parece una buena noticia que el viernes se lanze la version php4 lo estaba esperando desde hace mucho tiempo bueno te dejo un codigo que parese funcionar bien
http://e.leven.com.ar/u2b/downloads/1.0.zip
Great job! I’m can’t wait to start modifying it. I have a few personal ideas that I want to try out myself that I’ve been working on.
Well post them! Come on! That’s the point! Open source! Community!
Share your ideas.
SE optimized url’s but don’t think many people would care about them much. I hoping that I will still be able to intergrate your script with other forum and cms scripts. A download option would be good especially if it will be able to convert on the fly.
I am quite curious to see how this API works out.
I have a few sites that are already depending on a custom script and setup, but one thing that could be interesting would be to have API calls to check and verify a video is still available.
Lars,
I’ll look at putting this into a class method for ya ;)
OK its friday time to post the script so I can start to get to work on it :)
Friday indeed post that baby
Now I’m wondering if they forgot. You ever waiting inline for a new gaming console. This is looking like deja vu to me. LOL
yeah I was waiting myself, I thought it would be out by now.
Hi.
It is cool..
So when will you upload new version?
Hi its good script for youtube galery.i tried make a scripts seo friendly but i didn’t .if you make this script its very usefull ..
I have a added a few things to make it more SEO friendly. I’m waiting for this new version to come out so I can add it to it, if anything needs to be changed from my original.
I also made some changes to fix some errors but its really useless because the new version fixes them and more, not sure why the owner haven’t responded to us since the 17th but was active in other post on the site.
hey!
It’s not as easy as it sounds :) Sorry to miss the deadline, but personal matters have gotten in the way. I’m not duckin’ your comments, just busy that’s all…DSL sucks too so my house is out of internet.
I’ll keep you posted.
LOL of course DSL succs. Thanks for letting us know what’s going on.
de donde se descarga?
Great work on the class. Waiting anxiously for the update! heheheh
Well since I’m almost done setting up a new site, I really wanting to intergrated this script with it. I had a few ideas about intergration with it. I’m sure everyone is understanding personal matters comes first though.
Any update on this?
I was wodnering that too. We went way pass the due date.
I don’t see any support for search by title? (The official api doesn’t even have this)
Lotsa love to you! It IS the missing secret ingredient for your class, right? - that was a hint ;-)
It’s been a while since any word of the new version.
I’m still waiting the upload of the new version…
Great Class! cant wait to start playing with the new version. Have a thanks and a link from my site to yours.
Just checking if a new date is set to release the new code? Looking forward to using the new features! thx
any updates on this being released?
I need the coding to display related video in the video player page ajax
any idea how to add comment system?
Please help
friday… which year?
Fatal error: Cannot use string offset as an array in /home/friend/public_html/videos/youtube.class.php on line 177
I get errors like this very frequently when loading pages, has this been fixed?
how long before new release
Also interested if this has been released yet? Couldn’t locate a download button as in the previous post.
Wow I almost forgot all about this. I wondering what happened to the new version aswell.
buen reproductor de videos youtube yu mas lo pueden descargar de http://pcxd.com.ar
Hi,
I am longtime waiting for your new version. Any good news? Please…..
Hello! Great stuff! I read the first post and look forward to seeing a new version. Second, do you do simple custom jobs for the clueless like myself? I don’t know where to begin.
Thanks!
Bryan
where is the link for the new version, will you gona post it here or update the download link on first version page?
Is the new version to use in php4 also released? If yes where is the link to download.
I got to use the other one on php5 . It is working. But i need in PHP4.Please reply
Bryan, you’re the real genius behind this YouTube script I found at HotScripts.com (http://www.hotscripts.com/Detailed/74755.html).
I was wondering if you could take a look at the script and tell me, us, if it gets your stamp of approval: http://ooglester.com/
I’m not a coder and it makes me nervous using scripts from sources that aren’t yet proven to be trustworthy.
And because you have the potential for greatness, could you also make a move to create a downloadable script along the same lines as this ooglester character?
Package it in one simple download. I’d pay money for that. I think you have lighting here! :D
ONLINE - DRUGSTORE!
PRICES of ALL MEDICINES!
FIND THAT NECESSARY…
VIAGRA, CIALIS, PHENTERMINE, SOMA… and other pills!
Welcome please: pills-prices.blogspot.com
NEW INFORMATION ABOUT PAYDAY LOANS!
Welcome please: payday-d-loans.blogspot.com
GOOD LUCK!
Seeds for Wealth:
Meshach and I are collaboratively the genius’ behind the YouTube API class.
I don’t mind, but I’d appreciate a link back to this blog on your software if you did in fact build off of ours.
Just give credit where credit is due is all we ask.
“by waxjelly.com” or anything will do, thanks.
@bryan
First let me say thanks so much for this wonderful script. It is AWESOME!!!
I have been working hard on a site using ooglester’s adaptation. I just wanted to share it with you.
http://www.ubuntuce.com/uketube/index.php
http://www.ukulelevideos.com (once forwarding begins)
I have a link back to this site as well. :)
Thanks, Jereme
http://www.TheJesusTV.com
Quick dirty fix for the empty result error.
LOCATE:
$this->return = file_get_contents(youtube::return_call());
ADD AFTER:
$contentword = “length”; //word to look for.
$contentword = preg_match( “/$contentword/i”, $this->return ); // //locate word lenght from youtube query which is not found if the there are no videos results.
if($contentword != “”)
{
echo “no results”;
// do a redirect here with or whatever…
die();
}
else {
//there are results
}
IMPORTANT, CHANGE THE “” AND ” …. (this bogs changes them)…
good luck
4 months and about 24 “fridays” later… is the new version ready yet?
hi Bryan, i’m not a php programmer but i’ve fixed some minor things as ugly photo id number appearing on top of the page, and broken pagination problem (just add the variable pagenumber to the links).
But i need to solve 2 things:
1)how to use more than one tag for search (example: italy + food)
2) how to sort “most recent” results for the my tags. Could you help me writing me via email please?
sgrunt
thanks to you the id is fixed - remove the echo(which is in the class.php)
please can you say exactly how you did the broken pagination problem.
has anyone managed to fix the related video problem
where the related may be example 8 more pages
now it just keeps going so you get page 9 of 8 page 10 of 8 etc..
needs fioxing or search engines will see it as double content and a waste site
I have updated my two sites with the new YouTube API!
I used a different script that is available at http://www.bizzarmedia.com for $5.00. (I am not the developer).
You can check out my new updated sites below.
http://www.UkuleleVideos.com
http://www.LinuxClips.com
Thanks, Jereme
nice script also…
These sites are now using a different script available at http://www.phpytsite.org/ .
Jereme
http://www.UkuleleVideos.com
http://www.LinuxClips.com
http://www.MythTube.com
http://www.GeekyVids.com
http://www.TheYouTubeDownloader.com
Hi!
So nobody have the new version? Where it can be downloaded? I’ve integrated it into joomla and seyret (a fantastic video component) but it’s really full of bugs…
Hi
I would like to show the videos just in Thai Languages.
How can I set the YouTube API.
Many Thanks
ma
can i post here?
We have just added a new YouTube Downloader Script at http://www.ooglester.com!
Thanks, Jereme
http://www.TheFreeTube.com
is there any link for the new version. Please reaaly nice script but I only can find the v1. And my online server runs on PHP4.
Thanks in advance
Wow I’ve been gone for so long finally found the address here again and I missed this. Wow I am so behind right now.
Is a nice script, but i phink you can use more web2.0, like ajax…
When i make a search, and i go to page 2, i need load the embebed video all time. And, if i have in page 5, and click in a video, when video play, videos page resulto go to page 1 :(
I use in http://ronaldogoal.com
P.S-sorry my bad english:)