Home arrow PHP arrow Page 4 - Getting Data from Yahoo Site Explorer Inbound Links API using PHP

Getting the data - PHP

In the first part of this two-part series, you learned the importance and principles of Yahoo Site Explorer's inbound links API with respect to search engine optimization. If you read that part, you should already have your application ID, which will be used in your PHP script to make API calls. Also discussed in the first part is how to formulate the GET Request URL, and how to understand the responses from the inbound links API. In this part, you will start consolidating all of those inputs and implement what you've learned using a PHP server side scripting language.

  1. Getting Data from Yahoo Site Explorer Inbound Links API using PHP
  2. Unserializing the data
  3. Getting the data you need from the API raw response
  4. Getting the data
By: Codex-M
Rating: starstarstarstarstar / 2
November 19, 2009

print this article



Based on the previous section's analysis of PHP code, you can easily grab important data. For example, say you need the title tag of all backlink URLs.


$display= $unserialized ['ResultSet'];


This is the command to penetrate from the outermost array to the results array, and then, by the properties of combinational array, the title tag can be called as:


Where $x is the counter of the array (example: 0 for the first back link, and 2 for the third back link.)

The final PHP code required to make a request to the Yahoo API, grab the response and finally display the title tag of all back link URLs to the browser is as follows:


//Step 1. Report possible errors for debugging


//Step 2. Declare the request variable

$request='http://search.yahooapis.com/SiteExplorerService/V1/inlinkData?appid= TrnTAC3V34FlhDKeOScqpmw42Tu8B4BI8VUI7awsdcvfYIjJDwbtnb4rfNmmeQ--&query=http://www.php-developer.org&results=3&output=php';

//Step 3. Read the responses from Yahoo inbound links API and put into a string.

$response = file_get_contents($request);

//Step 4

if ($response === false) {

die('The request fails.');


//Step 5. Convert to unserialized

$unserialized = unserialize($response);

//Step 6. To display the array in the browser:

echo '<pre>';


echo '</pre>';

echo '<br />';


$display= $unserialized['ResultSet'];




$count= sizeof($display1);

//echo $count;

while ($x < $count) {

echo $display1[$x]['Title'];

echo '<br />';




Take note that the WHILE loop has been used to iterate the grabbing of data from the first back links with array [0] to the maximum size of the array, determined by the sizeof() function.

>>> More PHP Articles          >>> More By Codex-M

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort


- 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: