Asked  2 Years ago    Answers:  5   Viewed   43 times

I have been trying for quite a while to check if submitted links are valid film-clips from or but I didn't succeed.

Any ideas how to check url's like: (valid) (not valid) (valid) (not valid) (not valid) (valid) (not valid) (not valid)


I use php.



i see a answer in this site :

and he said :

I would suggest using youtube's API since you are trying to validate if the video exists. or if you don't want to go into API stuff then you can do simple trick. check this link:

to check for the existence of a video you will need to extract "v" value and send a request that contains the video id to :

where videoID is the "v" value for example a video FLE2htv9oxc will be queried like this if it does not exist then you will get a page with "Invalid id" if it exists, will return an XML feed having various info about the video. this way you can check that the video exists.

hope this will get you in the right direction.

the same thing with vimeo , try to look in api documentation in there site.

Thursday, November 24, 2022

You can just use the built in array_filter

If no callback is supplied, all entries of input equal to FALSE (see converting to boolean) will be removed.

So can do this in one simple line.

if(!array_filter($array)) {
    echo '<li>Please enter a value into at least one of the fields regarding the request you are searching for.</li>';
Tuesday, October 18, 2022

Try this:

$str = ' file [that] needs "to" be (encoded).zip';
$pos = strrpos($str, '/') + 1;
$result = substr($str, 0, $pos) . urlencode(substr($str, $pos));

You're looking for the last occurrence of the slash sign. The part before it is ok so just copy that. And urlencode the rest.

Thursday, November 3, 2022

According to the PHP manual, you must specifically encode a URL if it contains special characters. This means the function itself should do no special encoding. Most likely your URL is being encoded before being passed to the function, so pass it through urldecode first and see what happens.

Edit: You're saying the encoding is being messed up. Again the PHP manual specifically states that you need to encode urls prior to passing them to file_get_contents. Try encoding the URL, then passing it to the function.

$url = urlencode($url);
Thursday, September 22, 2022

You need to use the YouTube iFrame API. Keep in mind, I know just the bare basics of Javascript and so on so this could potentially be a lot more efficient.

You them embed your iframe as you normally would

<iframe id="player" width="640" height="360" src="" frameborder="0" allowfullscreen></iframe>

But with a couple changes. It needs to have an ID, 'player', and you need to append ?enablejsapi to the end of the source URI.

You'll then need to run the following script to load the API JS as well as creat the player

// 2. This code loads the IFrame Player API code asynchronously.
      var tag = document.createElement('script');
      tag.src = "";
      var firstScriptTag = document.getElementsByTagName('script')[0];
      firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);

  // 3. This function creates an <iframe> (and YouTube player)
  //    after the API code downloads.
  var player;
  function onYouTubePlayerAPIReady() {
    player = new YT.Player('player', {
      height: '390',
      width: '640',
      videoId: 'u1zgFlCw8Aw',
      events: {
        'onReady': onPlayerReady,
        'onStateChange': onPlayerStateChange

Notice that new YT.Player('player' should match your iframe ID and that videoId: 'u1zgFlCw8Aw' should match the src URI.

After this you'll be able to run scripts like

var myPlayerState;
      function onPlayerStateChange(event) {
        if ( == YT.PlayerState.PLAYING && !done) {
          // DO THIS
        myPlayerState =;

if (myPlayerState == 1){
Tuesday, October 4, 2022
Only authorized users can answer the search term. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :

Browse Other Code Languages