youtube api - PHP: Verifying YT video id exists through YT APIs -


Research seems to be the best practice through YT APIs when YT Video ID is present. I am a new learner for PHP and have created a function, but there are errors in it, I am not sure whether it is reaching correctly or if I have to change my code. How can I verify a YouTube video ID properly?

I'm getting two errors:

  WARNING: Incorrect parameter count for preg_replace () Fatal error: Class 'HTTP' not found  < / Pre> 

code

  function is valid Youtube video ($ isValid) {$ isValid = false; If ($ videoID == preg_replace ('~ https ?: // (?: [0- 9A-Z-] + \.)? (?: Youtu \ .be / | youtube \ .com \ s * [^ \ W [-] '] [^ <> <> |    

The best way to check with YouTube's API is by doing this method I worked with:

  $ headers = get_headers ('http://gdata.youtube. Com / feeds / api / videos / '. $ Video id); If (! Stros ($ headers [0], '200')) {echo "The YouTube video you entered does not exist"; Return Return;}   

Simply copy and replace with the rest of your code is good to go.

Comments

Popular posts from this blog

Python SQLAlchemy:AttributeError: Neither 'Column' object nor 'Comparator' object has an attribute 'schema' -

java - How not to audit a join table and related entities using Hibernate Envers? -

mongodb - CakePHP paginator ignoring order, but only for certain values -