If you’re anything like me, then you may want to see how the previously defined “WebSearchService” class can work under real conditions. Therefore, below I set up a concrete example that shows how the class in question returns 15 different entries associated with the string “Devshed.com” to client code, naturally fetched by the respective Yahoo! Web Search Service. Here’s the corresponding code sample, along with the pertinent list of results: try{ // create new instance of 'WebSearchService' class $ws=new WebSearchService(); // set search query $ws->setQuery('Devshed.com'); // set number of search results $ws->setNumResults(15); // display search results echo $ws->getSearchResults();
} catch(Exception $e){ echo $e->getMessage(); exit(); } // displays the following Open Source Web Development Tutorials - Dev Shed Offers a complete line of information on web page http://www.devshed.com/ Webmaster Tools, Developer Tools, Programming Tools - Do you know who your target audience is? If you don't http://tools.devshed.com/ Web Hosting, Web Hosting Help, Web Hosting FAQs, Web Hosting, Web Hosting Help, Web Hosting FAQs, http://webhosting.devshed.com/ PHP Help, PHP Programming, PHP Code, PHP Tutorials A wide range of tutorials and articles with a growing http://www.devshed.com/c/b/PHP/ PHP Security Mistakes Email Me Similar Content When Posted. Add Developer http://www.devshed.com/c/a/PHP/PHP-Security-Mistakes/ Creating a Secure PHP Login Script Email Me Similar Content When Posted. Add Developer http://www.devshed.com/c/a/PHP/ MySQL Help, MySQL Tutorials, MySQL Programming, MySQL A collection of MySQL tutorials on Administration, and http://www.devshed.com/c/b/MySQL/ Linux Web Hosting Find your next Linux Web Host now! Search through http://www.devshed.com/linux-web-hosting Perl Help, Perl Programming, Perl Code, Perl Tutorials, A five-part beginning perl series that covers topics from http://www.devshed.com/c/b/Perl/ Dedicated Servers Find your next Dedicated Servers Host now! Search http://www.devshed.com/dedicated-servers Small Business Hosting Find your next Small Business Host now! Search through http://www.devshed.com/small-business-hosting Web Development Archives, Web Developer Archives, FAQs, Web Development archives, containing a multitude of http://archives.devshed.com/ E-Commerce Hosting Find your next E-commerce Web Host now! Search through http://www.devshed.com/e-commerce-hosting High Performance Web Caching With Squid Article on tuning Squid on Linux for maximum performance http://www.devshed.com/c/a/Administration/High- Database Programming in Python: Accessing MySQL Database Programming in Python: Accessing MySQL by http://www.devshed.com/c/a/Python/ See how easy it is to query the Yahoo! Web Search Service using the PHP class that I built before? I guess you do! In this case, this class comes in handy for hiding all the business logic required to implement this specific Yahoo! web service behind its API, and its use demands only a few lines of PHP 5 code. All in all, I showed you how to use a compact PHP class to query the Yahoo! Web Search Service and eventually return the corresponding results to client code. So, what is the next thing to do now? Well, due to the flexible nature of the class that you learned before, it’s possible to build a similar one that works with the Yahoo! Video Search Service instead, without having to completely modify its structure. Therefore, in the last section of this tutorial I’m going to show you how to build such a class. But as you might have guessed, to see the details of this process, you’ll have to click on the link below and keep reading.
blog comments powered by Disqus |
|
|
|
|
|
|
|