Let's see how to use RESTClient
class to consume the Yahoo spelling suggestion service.
<?php require "RESTClient.php"; $client = new RESTClient(); $result = $client->get( "http://search.yahooapis.com/WebSearchService/V1/ spellingSuggestion", array( "appid" => "YahooDemo", "query" => "apocalipto")); printf("Response = %s <br>", htmlspecialchars($result)); ?>
First we require the PHP file with the class implementation.
require "RESTClient.php";
Next, create the RESTClient
class instance.
$client = new RESTClient();
And send the GET
request to the service.
$result = $client->get(
"http://search.yahooapis.com/WebSearchService/V1/
spellingSuggestion",
array( "appid" => "YahooDemo",
"query" => "apocalipto"));
Note that in addition to the service location URL, used as the first parameter, we have used the service request parameters as an array in the second parameter.