Take the 2-minute tour ×

I am using YouTube PHP API to retrieve a feed that searches for the exact term "super bowl commercials".

However, I sometimes get irrelevant videos in the feed.

$searchTerms stores the search query.

$searchTerms2 = str_replace(" ","+",$searchTerms);
$searchTerms2 = '"' . $searchTerms2 . '"';


Does any one know of a solution to this issue?

share|improve this question
show us the full api link –  Osa Jan 16 '13 at 17:55
add comment

1 Answer

up vote 1 down vote accepted

From reference: To search for an exact phrase, enclose the phrase in quotation marks. For example, to search for videos matching the phrase "spy plane", set the q parameter to %22spy+plane%22.

So you urlencode your quotation marks?

share|improve this answer
Could you please show me an example using PHP API? –  Michael Jan 18 '13 at 2:27
I don't have a PHP example, but as long as your url looks like https://gdata.youtube.com/feeds/api/videos?q=%22super+bowl+commercials%22&order‌​by=published&max-results=5&v=2 it should be fine. Try to debug it and output the final url to see whats going on in your script. –  bitWorking Jan 18 '13 at 12:06
add comment

Your Answer


