PHP
  Home arrow PHP arrow Getting Data from Yahoo Site Explorer Inbound Links API using PHP
Dev Shed Forums 
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Smartphone Development  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
iPad news and developer info.
Ads by affinity 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
VPS Hosting 
Forums Sitemap 
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
Google.com  
PHP

Getting Data from Yahoo Site Explorer Inbound Links API using PHP


By: Codex-M
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 2
    2009-11-19


    Table of Contents:
  • Getting Data from Yahoo Site Explorer Inbound Links API using PHP
  • Unserializing the data
  • Getting the data you need from the API raw response
  • Getting the data

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      error-file:tidyout.log Del.ici.ous error-file:tidyout.log Digg
      error-file:tidyout.log Blink error-file:tidyout.log Simpy
      error-file:tidyout.log Google error-file:tidyout.log Spurl
      error-file:tidyout.log Y! MyWeb error-file:tidyout.log Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article

     
     
    ADVERTISEMENT


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

    Getting Data from Yahoo Site Explorer Inbound Links API using PHP
    (Page 1 of 4 )

    The Basic Request and Response PHP Script

    Yahoo Site Explorer's inbound links API provides sample PHP code to make requests and for receiving responses. The API documentation for using PHP in the application can be found in two places, here and here. The sample script at the second link is a very basic PHP code and does NOT include processing of data.

    One of the first things you need to declare is to turn on reporting of all errors in PHP, which will be useful when debugging complicated and API applications:

    error_reporting(E_ALL);

    Next you need to declare your request variable. In the first part, you learned that this request URL will be used as a GET request to Yahoo.

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

    The detailed discussion in how to formulate a GET request URL for Yahoo inbound links explorer API can be found in the part one of this tutorial.

    Now that you have made a request, the vital third step is to receive the data from the Yahoo inbound links API and put into a string compatible for PHP processing. Using a PHP function called file_get_contents(), the entire response from Yahoo can be read into a string.

    So it will be:

    $response = file_get_contents($request);

    IMPORTANT NOTE: Some web hosting companies, particularly those that offer free hosting plans, disable the file_get_contents PHP function. So it is highly recommended to check first with your hosting agency to make sure that the function has been enabled. If this is disabled, it appears to be impossible to develop useful PHP web applications with the API.

    To detect problems with the response and receive process, you will need a conditional statement after the file_get_contents function:

    //Step 4

    if ($response === false) {

    die('The request fails.');

    }



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

       

    PHP ARTICLES

    - PHP Excel Customizations: Working with Formu...
    - MVC and the Zend Framework
    - PHP: Rendering Web Pages Using the Composite...
    - PHP: Creating Dynamic Web Pages with the Com...
    - Secure Encrypting and Decrypting for Your PH...
    - PHP: Creating Single View Objects with the C...
    - PHP: View Object Collections and the Composi...
    - Securing Your PHP Website
    - Determine Link Relevance and Unique Class C ...
    - PHP Composite View Design Pattern: Introduci...
    - Facebook PHP API Applications: A Second Look
    - Secure PHP Programming
    - Facebook PHP API Applications: Basic Introdu...
    - SOAP Servers and Web Services
    - Using XPath, SOAP, and More with Web Services


    Code Analysis Tools
    Enterprise code analysis tools that deliver quality and reliable code

     


     


    © 2003-2010 by Developer Shed. All rights reserved. DS Cluster 4 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek