Hi Guys
i am working in a site say sample.com. which should have a search engine . this search engine should search videos from another site say sample2.com or youtube.com for example.

it will only show thumbnail, views rating etc of the fetched video. and when user will click on that thumbnail or video then it will take you to that corresponding site sample2.com and then play that video there.

Any idea or tutorial about how to do this?


Many Thanks in advance.

Recommended Answers

All 5 Replies

well it all depends on what the site you are searching is.

if it is YouTube they have API available to search and get all the info you need, other sites might have APIs as well.

here is youTubes PHP API reference http://code.google.com/apis/youtube/code.html#PHP

If the site doesn't have an API you could figure out there search URL and then parse the output for video info.

Thanks for the reply , i want to do it without using API. can you please let me know how to pass the url and where can i find the script which accepts the url of site from which we want to search videos?

Many thanks in advance.

Well, again it all depends on the site you want to search, but just run a search on there site and look at the URL (if its a GET query, POST you will have to dome a little digging).

YouTube for example looks like

http://www.youtube.com/results?search_query=cool+video&aq=f

so all you have to do is change cool+video with the term you want with URL encoding and read the return. Then you have to figure out a way to parse the HTML using some regular expressions and get the data you want.

or API

<?php
$query = $yt->newVideoQuery();
$query->setQuery($searchTerm);
$feed = $yt->getVideoFeed($query);

ListResults($feed);
?>

Great! you look like a super expert but i am just a learner :-(
So can you please provide some references of similar tutorials?


Thanks

Well to use API, i posted the link for YouTube, for other sites, best is to just google the sites name and API.

if you are looking for tutorials on the non API method, I haven't really looked for any. Best bet for that would be to look for some PHP RegEx tutorials on Google as well.

Heres a simple example that came up when searching php parse data from html - http://www.phpro.org/examples/Parse-HTML-With-PHP-And-DOM.html

Hope this helps you out

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.