USESEO - Essential Guide to Search Engine Optimization

Free Search Engine Optimization techniques

What can Yahoo API do?

Yahoo has been improving their API usability for the last few months. Learning how to use it effectively will certainly help the developers to create their own powerful applications. Apart from the standard search operators, they have introduced specific API to grab a page's details such as pages in a domain or the pages that link to a specific page or site.

How to get started?

Joining the Yahoo developer network is easy and hassle free. Follow the steps below to start using their APIs:

  1. Read their online FAQs
  2. Request for an application ID.
  3. Download the Software Development Kit with lots of useful examples.

A working example- Get the number of inbound links

Nothing is better than a live example. In the following example, we will be using the Inbound links API with serialized PHP output to illustrate (this is the most easy way to start off). The following form accepts an URL that will eventually be passed to Yahoo for analyze.

<form name="form" method="post" action="yahooexample.php">
<input type="text" name="url">
<input type="submit" name="submit" value="Get Links">
</form>

Upon submitting the above form, we will have to check if the entered URL it is a valid page. We can perform this check by:

<?php
$check_link=$_POST['url'];
$html= @file_get_contents($check_link);
if($html) {
// pass to Yahoo to get Inbound links details
}
else //output invalid page
?>

Now we are prepared to construct the queries. Refering to the official parameters, we can get 100 results per query but since we just want to get the number of incoming links to a page, one query is enough for us. The following query will ask Yahoo to return us the number of incoming links to the entered URL.

<?php
// Replace YahooDemo with your application ID
$request = 'http://search.yahooapis.com/SiteExplorerService/V1/inlinkData?appid=YahooDemo&query=';
$request.=$_POST['url'];
$request.='&output=php';
$output = unserialize(file_get_contents($request));
$incoming_links=$output[ResultSet][totalResultsAvailable];
?>

The resulting number of links will be stored in the variable, $incoming_links. It is recommended to use Yahoo API for getting the number of inbound links of a site or page because they allow the full set of data to be displayed unlike Google. As this API is only at its first version at the point of writing, Yahoo may come up with even more useful and powerful upgrades in future.

The above shows a simple demostration of how to get the number of inbound links through Yahoo API. Please feel free to contact me if you have further problems regarding this API.