hey hii everyone,
i have a function to fetch the videos from the rss feed of youtube, so that i can display selected videos to my blog
for that i am using this youtube-search-feed url
http://gdata.youtube.com/feeds/base/videos?q=eminem&client=ytapi-youtube-search&v=2
in the url, eminem is included, so it will display me videos of eminem, now my problem is, instead of eminem it should take my posts title name, so if i write this code
$rss = fetch_rss('http://gdata.youtube.com/feeds/base/videos?q='.the_title().'&client=ytapi-youtube-search&v=2');
then its returning me with a false video
here is my entire code
<?php
$newvar = str_replace(' ', '', the_title());
include_once(ABSPATH . WPINC . '/rss.php');
$rss = fetch_rss('http://gdata.youtube.com/feeds/base/videos?q='.$newvar.'&client=ytapi-youtube-search&v=2');
$maxitems = 1;
$items = array_slice($rss->items, 0, $maxitems);
?>
here i am using $newvar to strip the spaces in between of the title of the posts
@rarst i change the code but now i am not getting the video
here is the code
<?php
$newvar = str_replace(' ', '', the_title());
include_once(ABSPATH . WPINC . '/feed.php');
$feed = fetch_feed('http://gdata.youtube.com/feeds/base/videos?q='.$newvar.'&client=ytapi-youtube-search&v=2');
$maxitems = 1;
$items = array_slice($feed->items, 0, $maxitems);
?>

fetch_rss()is very outdated and deprecated, please usefetch_feed(). – Rarst♦ Jan 11 '11 at 13:07urlencode()around the title, so you never have problems with special characters in the title. This way you don't have to remove spaces. – Jan Fabry Jan 11 '11 at 13:28fetch_feed()but now i am getting no videos check my og answer for current edited code – ntechi Jan 11 '11 at 13:53urlencodeas @Jan Fabry pointed out will give you better results, but you should get search results either way. Can you show us the code that displays the results? Or tryvar_dump($items)to see what format the results are in? – goldenapples Jan 11 '11 at 16:59