Creating and consuming web services using PHP
PHP can be used for creating and consuming web services. PHP has powerful libraries for creating and consuming web services that use SOAP or XML-RPC or REST.
Let's try to understand how to consume web services in PHP using a simple example. In this example, we're going to get the details of a phrase from the API of Wikipedia.
Getting ready
Wikipedia (http://www.wikipedia.org) is a free web-based multilingual encyclopedia. Almost all of its articles can be edited by anyone if they have more information about the subjects. It is probably the largest and most popular website where people find information about general knowledge or specific topics. Currently, Wikipedia has articles in 282 languages.
How to do it...
Wikipedia has an API at http://en.wikipedia.org/w/api.php, which can be used for various purposes to access and modify the information at Wikipedia.org. In our example, we're just getting an explanation of a term using Wikipedia.
To invoke the...