HomePHP Using Yahoo Web Services to Perform Searches with an Object-Oriented Approach
Using Yahoo Web Services to Perform Searches with an Object-Oriented Approach
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.
As you’ll possibly recall, in the last tutorial of this series, I finished discussing the use of the popular Yahoo! Image and Video Search services with PHP 5 by utilizing some custom PHP functions that were actually very easy to grasp and code. Basically, I defined a bunch of procedural functions for implementing a specific Yahoo! Web Service, and for creating small, yet efficient, pieces of code that can be reused easily within the context of different PHP 5 applications.
Implementing one or more Yahoo! Web Services by way of a procedural approach has certain advantages, since this procedure can be tackled without the use of sophisticated programming techniques. And it only requires an intermediate background in some of the most common PHP native functions, such as the familiar “file_get_contents(),” the “foreach” construct, and a few others.
However, at this point it’s quite possible that the following question is already spinning in your mind: what should I do if I need to implement a specific Yahoo! web service within an existing PHP 5 application that has been previously built using an object-oriented approach? Well, actually I’m glad to see you came up with such a useful dilemma!
Coupling a concrete Yahoo! web service with an existing object-based PHP 5 application isn’t as difficult as it may seem at first sight, particularly if you’ve spent some time working with classes and objects. And speaking of PHP classes, they bring me straight to the subject of this fifth part of the series, since in the next few lines I’m going to show you how to implement some of the Yahoo! Web Search Services that you learned in the previous articles, but this time using the object-oriented paradigm.
Sounds pretty interesting, right? In simple terms, my plan will consist of creating some compact and modular PHP 5 classes, which will define a few basic methods for working with the different web services offered by Yahoo!.
Hopefully, by the end of this article, you’ll be equipped with the required background to implement one or more of these useful Yahoo! search services by using an object-based approach. Thus, let’s get rid of the preliminaries and start learning how to achieve this goal with PHP 5. It’s going to be an instructive journey, trust me!