Jump to content

Get_Headers For Youtube Video Validation


doofy

Recommended Posts

Essentially all I am trying to do is loop through 10 youtube videos, IF they are active videos. Right now the get_headers function seems to be stopping the while loop after the first go.

 

I'm a newb still, so any help with this would be EXTREMELY appreciated! I'm sure it's something simple that I'm just not grasping.

 

while($row = mysql_fetch_array($result))
   {

   $headers = get_headers("http://gdata.youtube.com/feeds/api/videos/".$row['YouTubeURL']."?v=2&alt=jsonc");

   if (strpos($headers[0], '200'))
       {

       if ($row['VideoID']!=$VideoID)
           {
           echo "<tr>";
      	 echo "<td align='left' valign='top' width='200'>";
           $json = json_decode(file_get_contents("http://gdata.youtube.com/feeds/api/videos/".$row['YouTubeURL']."?v=2&alt=jsonc"));
           echo '<img src="' . $json->data->thumbnail->hqDefault . '" alt="'.$row['Title'].'" border=0 width="200">';
           echo "</td>";
           echo "<td align='left' valign='top' width='250'>";
           if (empty($Category))
               {
               echo "<a href='?VideoID=".$row['VideoID'].$pagelink."'>".$row['Title']."</a><br/><br/>";
               }
               else
               {
               echo "<a href='?Category=".$row['Category']."&VideoID=".$row['VideoID'].$pagelink."'>".$row['Title']."</a><br/><br/>";
               }
           echo "<br /><br />";
           echo "<b><font size='1'>";
           echo " Video Added: ";
           echo $row['DateStamp'];
           echo "</b></font><br /></tr>";
           }

       return true;
       }
   }

       return true;
       }
   }

 

return means that PHP will exit that function, so your first video to return a 200 status is going to cause the script to jump out of that function and back to wherever you called that function from. Near as I can tell from the code given, you probably just want to remove that line so the loop can continue.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.