Home arrow PHP arrow Page 3 - Using Yahoo Web Services to Perform Searches with an Object-Oriented Approach

Testing the previous “WebSearchService” class - PHP

If you’re a PHP developer who wants to take the first steps toward building web applications that interact with specific web services, in this article series you’ll find an approachable guide to implementing some of the most useful search services provided by Yahoo! by using a few simple PHP scripts.

TABLE OF CONTENTS:
  1. Using Yahoo Web Services to Perform Searches with an Object-Oriented Approach
  2. Building a web search class with PHP 5
  3. Testing the previous “WebSearchService” class
  4. Building a video searching class with PHP 5
By: Alejandro Gervasio
Rating: starstarstarstarstar / 2
February 12, 2008

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement

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
design tips, java scripting guide, shareware HTML
editor, and web server software and setup.

http://www.devshed.com/

Webmaster Tools, Developer Tools, Programming Tools -
Dev Mechanic


Do you know who your target audience is? If you don't
know, you are not ... When faced with diminishing sales
or a shift in profitability, sometimes a ...

http://tools.devshed.com/

Web Hosting, Web Hosting Help, Web Hosting FAQs,
Find Hosting - Web Hosting


Web Hosting, Web Hosting Help, Web Hosting FAQs,
Find Hosting - Web Hosting ... In this second part, I
want to get more specific about the types of hosting ...

http://webhosting.devshed.com/

PHP Help, PHP Programming, PHP Code, PHP Tutorials


A wide range of tutorials and articles with a growing
PHP section. ... Formerly referred to as "Personal Home
Page Tools," PHP Hypertext Preprocessor ...

http://www.devshed.com/c/b/PHP/

PHP Security Mistakes


Email Me Similar Content When Posted. Add Developer
Shed Article Feed To Your Site. Email Article To Friend.
Print Version Of Article. PDF Version Of Article ...

http://www.devshed.com/c/a/PHP/PHP-Security-Mistakes/

Creating a Secure PHP Login Script


Email Me Similar Content When Posted. Add Developer
Shed Article Feed To Your Site. Email Article To Friend. Print
Version Of Article. PDF Version Of Article ...

http://www.devshed.com/c/a/PHP/
Creating-a-Secure-PHP-Login-Script/

MySQL Help, MySQL Tutorials, MySQL Programming, MySQL
Tricks


A collection of MySQL tutorials on Administration, and
Grant Tables. ... MySQL is an open source relational
database management system (RDBMS) ...

http://www.devshed.com/c/b/MySQL/

Linux Web Hosting


Find your next Linux Web Host now! Search through
our highly recommended Linux Web Hosting companies
and read our Web Hosting FAQs and Web Hosting articles
to help ...

http://www.devshed.com/linux-web-hosting

Perl Help, Perl Programming, Perl Code, Perl Tutorials,
Perl Development


A five-part beginning perl series that covers topics from
regular expressions to file manipulation to database
access for web developers.

http://www.devshed.com/c/b/Perl/

Dedicated Servers


Find your next Dedicated Servers Host now! Search
through our highly recommended Dedicated Servers
Hosting companies and read our Web Hosting FAQs
and Web Hosting ...

http://www.devshed.com/dedicated-servers

Small Business Hosting


Find your next Small Business Host now! Search through
our highly recommended Small Business Hosting companies
and read our Web Hosting FAQs and Web Hosting articles ...

http://www.devshed.com/small-business-hosting

Web Development Archives, Web Developer Archives, FAQs,
Mailing Lists, Newsgroups


Web Development archives, containing a multitude of
information spanning FAQs, ... Here you will find an
assortment of Mailing Lists such as Java Discussion,
MySQL ...

http://archives.devshed.com/

E-Commerce Hosting


Find your next E-commerce Web Host now! Search through
our highly recommended E-commerce Web Hosting companies
and read our Web Hosting FAQs and Web Hosting articles ...

http://www.devshed.com/e-commerce-hosting

High Performance Web Caching With Squid


Article on tuning Squid on Linux for maximum performance
and stability. ... Email Me Similar Content When Posted. Add
Developer Shed Article Feed To Your Site ...

http://www.devshed.com/c/a/Administration/High-
Performance-Web-Caching-With-Squid/

Database Programming in Python: Accessing MySQL


Database Programming in Python: Accessing MySQL by
A.P.Rajshekhar ... Email Me Similar Content When Posted.
Add Developer Shed Article Feed To Your Site ...

http://www.devshed.com/c/a/Python/
Database-Programming-in-Python-Accessing-MySQL/


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.



 
 
>>> More PHP Articles          >>> More By Alejandro Gervasio
 

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort
   

PHP ARTICLES

- Hackers Compromise PHP Sites to Launch Attac...
- Red Hat, Zend Form OpenShift PaaS Alliance
- PHP IDE News
- BCD, Zend Extend PHP Partnership
- PHP FAQ Highlight
- PHP Creator Didn't Set Out to Create a Langu...
- PHP Trends Revealed in Zend Study
- PHP: Best Methods for Running Scheduled Jobs
- PHP Array Functions: array_change_key_case
- PHP array_combine Function
- PHP array_chunk Function
- PHP Closures as View Helpers: Lazy-Loading F...
- Using PHP Closures as View Helpers
- PHP File and Operating System Program Execut...
- PHP: Effects of Wrapping Code in Class Const...

Developer Shed Affiliates

 


Dev Shed Tutorial Topics: