In one of my applications I am saving a YouTube video\'s id... Like "A4fR3sDprOE". I have to display its title in the application. I got the following code for getting
I would like to add to this that the specific error seen here (HTTP 402 - Payment Required, which is otherwise a HTTP status code that servers generally don't have implemented) is what YouTube returns when it has determined that an "excessive" amount of traffic has been coming from your IP address (or IP address range -- they do rather enjoy blocking OVH's IP address ranges on a frequent basis[1][2]).
Therefore, if you're accessing youtube.com (not the API) programmatically (using PHP or otherwise), you may eventually find yourself hitting this error. YouTube generally starts off by presenting CAPTCHAs to requests from "excessive traffic" IP addresses, but if you aren't completing them (which your PHP script won't be), they will switch to these unhelpful 402 responses with essentially no recourse - YouTube doesn't exactly have a customer support desk to call, and if you can't actually access any of their website because of the IP address blocking, you have even less chance of contacting them.
Other references:
http://productforums.google.com/forum/#!topic/youtube/tR4WkNBPnUo
http://productforums.google.com/forum/?fromgroups=#!topic/youtube/179aboankVg