开发者

Searching YouTube using API from PHP with more than one word in search term

I have been trying to use the YouTube API to search for videos from YouTube using the Zend Gdata class. When I type a search term with a开发者_开发知识库 single word I get back expected results but when I start using more than one work in my search term I dont seem to get back very good results, the videos do not seem to be related to my search term.

I urlencode the search term before passing it to youtube - ie

$query->videoQuery = urlencode($searchString);

Has anyone come across a similar problem? any solutions?


I'm not exactly sure how the Youtube API provides search results but you can try the following:

Option 1: (Adds quotes around the query)

$query->videoQuery = urlencode('"' . $searchString . '"');

Option 2: (Adds a '+' in front of each word)

$query->videoQuery = urlencode('+' . preg_replace('/\s+/', ' +', $searchString));
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜