how to create video site map for youtube and vimeo vodeos

0 votes
380 views
asked Nov 24, 2013 in PHP by seo tips
HI all

   how to create video site map for youtube and vimeo vodeos?

1 Answer

0 votes
answered Nov 24, 2013 by admin (8,115 points)

I am using the following code snipet fot creating video site map for my site..

<?php
include("includes/config.php");
include("youtubeurlmaker.php");
$newVideoQry = "YOUR Queryy";
$newVideoRst = mysql_query($newVideoQry);
 
while($newVideoAry = mysql_fetch_array($newVideoRst)) {
 
$newVideoUrl = $newVideoAry['url'];
$newVideoId= $newVideoAry['id'];
$description     =   $newVideoAry['description'];
$videoId = getYouTubeIdFromURL($newVideoAry['url']);
$thumbnail  = parse_youtube_url($newVideoAry['url'],'hqthumb');
$embedurl = parse_youtube_url($newVideoAry['url'],'embed');
$url =  "URL FOR VIDEO hosted in u r site";
$date = $newVideoAry['date'];
$hits = $newVideoAry['hits'];
 
$xml .= "<url> ";
      $xml .= "<loc>".$url."</loc>";
          $xml .= "<video:video>";
        $xml .= "<video:thumbnail_loc>".$thumbnail."</video:thumbnail_loc>";
        $xml .= "<video:title>".$description."</video:title>";
        $xml .= "<video:description>".$description."</video:description>";
        $xml .= "<video:content_loc>".$newVideoUrl."</video:content_loc>";
        $xml .= "<video:view_count>".$hits."</video:view_count>";  
       
        $xml .= "<video:family_friendly>YES</video:family_friendly>";  
            $xml .= "<video:live>YES</video:live>  </video:video>  </url>";
}
$xml .= "</urlset>";
echo($xml);
 
$fp = fopen("videosxmlsitemap.xml","wb");
if( $fp == false ){
    //do debugging or logging here
}else{
    fwrite($fp,$xml);
    fclose($fp);
}
 
function getYouTubeIdFromURL($url)
{
  $url_string = parse_url($url, PHP_URL_QUERY);
  parse_str($url_string, $args);
  return isset($args['v']) ? $args['v'] : false;
}
?>
...