1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Yahoo API to get the backlinks from yahoo

Discussion in 'Yahoo API' started by thecheapsters, Apr 18, 2008.

  1. #1
    Hi,

    i want to know that how to get the yahoo back links from yahoo using yahoo API in PHP, please hep me out the way to do that

    Thanks
     
    thecheapsters, Apr 18, 2008 IP
  2. ezcat

    ezcat Peon

    Messages:
    233
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Yeah, Me too... PM if you get this answer. Thanks!
     
    ezcat, Apr 24, 2008 IP
  3. snatcher

    snatcher Active Member

    Messages:
    219
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    90
    Digital Goods:
    1
    #3
    function getYahooLinks($domain) {
    $yahooAppId1 = "YOUR_YAHOO_KEY";
    $yahoourl="http://search.yahooapis.com/SiteExplorerService/V1/inlinkData?appid=".$appid."&query=".$domain."&entire_site=1&omit_inlinks=domain&results=1&output=php";
    $data = @file_get_contents($yahoourl);
    $results=unserialize($data);
    return $results['ResultSet']['totalResultsAvailable']; //$results[0][1];
    }
     
    snatcher, Apr 30, 2008 IP
  4. kookcoo

    kookcoo Peon

    Messages:
    81
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    How to use it?:eek:



    __________________
     
    kookcoo, Jun 25, 2008 IP
  5. wowla_123

    wowla_123 Peon

    Messages:
    147
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #5

    Like this:

    <?
    function getYahooLinks($domain) {
    $appid = "31245124213";
    $yahoourl="http://search.yahooapis.com/SiteExplorerService/V1/inlinkData?appid=".$appid."&query=".$domain."&entire_site=1&omit_inlinks=domain&results=1&output=php";
    $data = @file_get_contents($yahoourl);
    $results=unserialize($data);
    return $results['ResultSet']['totalResultsAvailable']; //$results[0][1];
    }
    
    echo getYahooLinks("digitalpoint.com");
    ?>
    PHP:
    It will tell u total number of backlinks.
     
    wowla_123, Jun 27, 2008 IP
  6. wowla_123

    wowla_123 Peon

    Messages:
    147
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #6
    If you want a complete working script (alonwith site names, URLs and paging), I'll post it here on Monday, as I'm busy right now.
     
    wowla_123, Jun 27, 2008 IP
    snvc likes this.
  7. KaoRi

    KaoRi Well-Known Member

    Messages:
    41
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    111
    #7
    wow, its great, im waiting for this information.
     
    KaoRi, Jun 27, 2008 IP
  8. wowla_123

    wowla_123 Peon

    Messages:
    147
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #8
    Here is the code. Save it as "index.php". It requires "xml.php" too.

    index.php

    <?php
    /*
    Title: Yahoo backlinks checker
    Author: Arsalan Jamshed
    Email: arsalan@indo-pak.org
    
    Feel free to modify or refine the code
    */
    
    ini_set('error_reporting', 'E_ALL & ~E_NOTICE');
    set_time_limit(60);
    include('xml.php');
    $domain = $_GET['domain'];
    ?>
    <br /><br />
    <p align=center><strong>Find Backlinks</strong><br />
    <form id="form1" name="form1" method="get" action="">
      Enter URL: 
        <input type="text" name="domain" id="domain" />
        &nbsp;<input name="Submit" type="submit" value="Submit" /> 
        (e.g google.com)
    </form>
    </p>
    
    <?
    if($domain!="")
    	{
    	$id  = '785437HGDer';  // enter your Yahoo API key here
    	$start = $_GET['res'];
    	$numresults = 16;
    	if($start=="")
    		$start = 1;
    	$url = 'http://search.yahooapis.com/SiteExplorerService/V1/inlinkData?';
    	$params = setParams($id, $start,$numresults, $domain);
    	$url = buildUrl($url, $params);
    	$data = getXMLArray($url);
    	$xhtml = formatYahooResultset($data);
    	}
    
    /**
     * Build an array with the parameters we want to use.
     *
     */
    
    function setParams($id,$start,$numresults, $domain)
    	{
    	$params = array(
    					'appid' => $id, 		
    					'query' => $domain, 
    					'results' => $numresults,
    					'entire_site' => '1',
    					'omit_inlinks'=> 'domain',
    					'start' => $start    
    					);
    	return $params;
    	}
    	
    	
    	
    /**
     * A url building function:
     *
     */
    
    function buildUrl($url, $params)
    	{
    	$qstring = ''; 			// Initialize...
    	foreach($params as $key => $value)
    		{ 			// Build query string...
    		$qstring .= '&'."$key=$value";
    		}
    	$qstring = ltrim($qstring,'&'); 	
    	return $url.$qstring;
    	}		
    
    
    
    /**
     * This function accesses an XML file ($url), reads it into a variable,
     * and then unserializes it into an associative array:
     */
    		
    function getXMLArray($url)
    	{
    	$xml = '';
    	
    	// Access the file ~ make the request:
    	$handle = fopen($url,"rb");
    	while (!feof($handle))
    		{
    		// Read the resulting XML into the variabl $xml:
    		$xml .= fread($handle, 8192);
    		}
    	fclose($handle);
    	
    	// Unserialize the data:
    	$data = XML_unserialize($xml);
    	return $data;
    	}
    
    
    
    function formatYahooResultset($data)
    	{
    	
    	$domain = $_GET['domain'];
    	
    	// If no results were found:
    	if($data['ResultSet attr']['totalResultsReturned'] == 0)
    		{
    		$results= "no result found";
    		return $results;
    		}
    	
    	// Now down to business:
           
        $tmp = "";
    	$mycounter=0;
    	foreach($data['ResultSet']['Result'] as $key => $value)
    		{
            $mycounter++;
    		$myurl = $data['ResultSet']['Result'][$key]['Url'];
    		$mytitle = $data['ResultSet']['Result'][$key]['Title'];
    		$tmp.="<a href='$myurl'>$mytitle</a><br><font color=green size=2>$myurl</font><br><br>";
    		}
    	$temp = $data['ResultSet attr']['totalResultsAvailable'];
    	$mycalculation = $data['ResultSet attr']['totalResultsAvailable'];
    		
    	$str = $_GET['p'];
    	$res = $_GET['res'];
    	$n_res = $res+10;
    	$pr_res = $res-10;
    
    	$temp = number_format($temp);
    	$enc = stripslashes($str);
    	$enc = stripslashes($enc);
    	$enc = urlencode($enc);
    
    	$mycalculation = $mycalculation-$res;
        
    	if($res!=1)    //if it is not the first page
    		{
    		if($mycalculation>=10)
    			{			
    			echo "<table align=center bgcolor=#F1E0F1 border=0 width=100%><tr><td align=center><font size=2 face=verdana><a href=index.php?res=$pr_res&domain=$domain><b>Previous Page</b></a> <font size=2 face=verdana>Approximately <b>$temp</b> results found. <a href=index.php?res=$n_res&domain=$domain><font face=verdana size=2><b>Next Page</b></font></font></a></center></td></tr></table></font>".$viewtext."<p>".$tmp."</p><table align=center bgcolor=#F1E0F1 border=0 width=100%><tr><td align=right><a href=index.php?res=$pr_res&domain=$domain><font face=verdana size=2><b>Previous Page</b></font></a>&nbsp;&nbsp;&nbsp;<a href=index.php?res=$n_res&domain=$domain><font size=2 face=verdana><b>Next Page</b></font></a></font></td></tr></table>";
    			}
    		else
    			{			
    		  	echo "<font size=1><table align=center bgcolor=#F1E0F1 border=0 width=100%><tr><td><center><font size=2 face=verdana><a href=index.php?res=$pr_res&domain=$domain><b>Previous Page</b></a></font><font size=2 face=verdana>Approximately <b>$temp</b> results found.</font></center></td></tr></table></font>".$viewtext."<p>".$tmp."</p><table align=center bgcolor=#F1E0F1 border=0 width=100%><tr><td align=right><a href=index.php?res=$pr_res&domain=$domain><font face=verdana size=2><b>Previous Page</b></font></a></td></tr></table>";
    		  	}
    		}
    	else       
    		{		
    	   	echo "<table align=center bgcolor=#F1E0F1 border=0 width=100%><tr><td><center><font face=verdana size=2>Approximately <b>$temp</b> results found. <a href=index.php?res=$n_res&domain=$domain><b>Next Page</b></a></font></center></td></tr></table>".$viewtext."<p>".$tmp."</p><table align=center bgcolor=#F1E0F1 border=0 width=100%><tr><td align=right><a href=index.php?res=$n_res&domain=$domain><font face=verdana size=2><b>Next Page</b></font></a></td></tr></table>";
    		}
    		
    	}
    
    echo "</font>";
    ?>
    PHP:
     
    wowla_123, Jun 30, 2008 IP
  9. wowla_123

    wowla_123 Peon

    Messages:
    147
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #9
    Here is xml.php. Place it in the same folder.

    <?php
    
    ###################################################################################
    # XML_unserialize: takes raw XML as a parameter (a string)
    # and returns an equivalent PHP data structure
    ###################################################################################
    function & XML_unserialize(&$xml){
    	$xml_parser = &new XML();
    	$data = &$xml_parser->parse($xml);
    	$xml_parser->destruct();
    	return $data;
    }
    ###################################################################################
    # XML_serialize: serializes any PHP data structure into XML
    # Takes one parameter: the data to serialize. Must be an array.
    ###################################################################################
    function & XML_serialize(&$data, $level = 0, $prior_key = NULL){
    	if($level == 0){ ob_start(); echo '<?xml version="1.0" ?>',"\n"; }
    	while(list($key, $value) = each($data))
    		if(!strpos($key, ' attr')) #if it's not an attribute
    			#we don't treat attributes by themselves, so for an empty element
    			# that has attributes you still need to set the element to NULL
    
    			if(is_array($value) and array_key_exists(0, $value)){
    				XML_serialize($value, $level, $key);
    			}else{
    				$tag = $prior_key ? $prior_key : $key;
    				echo str_repeat("\t", $level),'<',$tag;
    				if(array_key_exists("$key attr", $data)){ #if there's an attribute for this element
    					while(list($attr_name, $attr_value) = each($data["$key attr"]))
    						echo ' ',$attr_name,'="',htmlspecialchars($attr_value),'"';
    					reset($data["$key attr"]);
    				}
    
    				if(is_null($value)) echo " />\n";
    				elseif(!is_array($value)) echo '>',htmlspecialchars($value),"</$tag>\n";
    				else echo ">\n",XML_serialize($value, $level+1),str_repeat("\t", $level),"</$tag>\n";
    			}
    	reset($data);
    	if($level == 0){ $str = &ob_get_contents(); ob_end_clean(); return $str; }
    }
    ###################################################################################
    # XML class: utility class to be used with PHP's XML handling functions
    ###################################################################################
    class XML{
    	var $parser;   #a reference to the XML parser
    	var $document; #the entire XML structure built up so far
    	var $parent;   #a pointer to the current parent - the parent will be an array
    	var $stack;    #a stack of the most recent parent at each nesting level
    	var $last_opened_tag; #keeps track of the last tag opened.
    
    	function XML(){
     		$this->parser = &xml_parser_create();
    		xml_parser_set_option(&$this->parser, XML_OPTION_CASE_FOLDING, false);
    		xml_set_object(&$this->parser, &$this);
    		xml_set_element_handler(&$this->parser, 'open','close');
    		xml_set_character_data_handler(&$this->parser, 'data');
    	}
    	function destruct(){ xml_parser_free(&$this->parser); }
    	function & parse(&$data){
    		$this->document = array();
    		$this->stack    = array();
    		$this->parent   = &$this->document;
    		return xml_parse(&$this->parser, &$data, true) ? $this->document : NULL;
    	}
    	function open(&$parser, $tag, $attributes){
    		$this->data = ''; #stores temporary cdata
    		$this->last_opened_tag = $tag;
    		if(is_array($this->parent) and array_key_exists($tag,$this->parent)){ #if you've seen this tag before
    			if(is_array($this->parent[$tag]) and array_key_exists(0,$this->parent[$tag])){ #if the keys are numeric
    				#this is the third or later instance of $tag we've come across
    				$key = count_numeric_items($this->parent[$tag]);
    			}else{
    				#this is the second instance of $tag that we've seen. shift around
    				if(array_key_exists("$tag attr",$this->parent)){
    					$arr = array('0 attr'=>&$this->parent["$tag attr"], &$this->parent[$tag]);
    					unset($this->parent["$tag attr"]);
    				}else{
    					$arr = array(&$this->parent[$tag]);
    				}
    				$this->parent[$tag] = &$arr;
    				$key = 1;
    			}
    			$this->parent = &$this->parent[$tag];
    		}else{
    			$key = $tag;
    		}
    		if($attributes) $this->parent["$key attr"] = $attributes;
    		$this->parent  = &$this->parent[$key];
    		$this->stack[] = &$this->parent;
    	}
    	function data(&$parser, $data){
    		if($this->last_opened_tag != NULL) #you don't need to store whitespace in between tags
    			$this->data .= $data;
    	}
    	function close(&$parser, $tag){
    		if($this->last_opened_tag == $tag){
    			$this->parent = $this->data;
    			$this->last_opened_tag = NULL;
    		}
    		array_pop($this->stack);
    		if($this->stack) $this->parent = &$this->stack[count($this->stack)-1];
    	}
    }
    function count_numeric_items(&$array){
    	return is_array($array) ? count(array_filter(array_keys($array), 'is_numeric')) : 0;
    }
    ?>
    PHP:
     
    wowla_123, Jun 30, 2008 IP
  10. RobPinnacle

    RobPinnacle Active Member

    Messages:
    423
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    58
    #10
    Interesting post, can you do the same with Google?
     
    RobPinnacle, Jun 30, 2008 IP
  11. Publisher-For-You

    Publisher-For-You Peon

    Messages:
    33
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #11
    Thanks Wowla, I installed your code, and it works nicely.

    I'm trying to get ALL my backlink data, so I can import it in to my own application.

    Or, I'm looking for a way to get the number of unique domains that link to me, and a list of those domains.

    I'm posting here so that if you decide to include these features in your script, I'll get a thread update notice.

    Thanks for your work!
     
    Publisher-For-You, Jul 29, 2008 IP
  12. seo alchemist

    seo alchemist Greenhorn

    Messages:
    80
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    23
    #12
    That's exactly what I was looking for. Thanks man!
     
    seo alchemist, Aug 18, 2008 IP
  13. ludovic115

    ludovic115 Peon

    Messages:
    131
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #13
    thx s man ur the best!!
     
    ludovic115, Aug 27, 2008 IP
  14. DomainCo.US

    DomainCo.US Well-Known Member

    Messages:
    2,124
    Likes Received:
    18
    Best Answers:
    0
    Trophy Points:
    100
    #14
    This is handy, I will include it in one of my sites. Thanks
     
    DomainCo.US, Aug 27, 2008 IP
  15. Final Expense Leads

    Final Expense Leads Well-Known Member

    Messages:
    65
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    128
    #15
    Thanks wowla!

    Your script works better than the commercial products I've been using for backlinks. Any thoughts on producing our link tools or incorporating more functions?

    Do let me know please if you produce an enhanced tool.
     
    Final Expense Leads, Oct 27, 2008 IP
  16. tukarinfobispak

    tukarinfobispak Peon

    Messages:
    702
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    0
    #16
    and how to get yahoo bot last visit ?
     
    tukarinfobispak, Nov 7, 2008 IP
  17. Duratec

    Duratec Banned

    Messages:
    169
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #17
    need to know this too! :S
     
    Duratec, Nov 10, 2008 IP
  18. Hastur

    Hastur Guest

    Messages:
    88
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #18
    Do these codes work for you? I have problems with both of them.
     
    Hastur, Nov 21, 2008 IP
  19. thuankkk

    thuankkk Active Member

    Messages:
    503
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    95
    #19
    thank you for the code :)
     
    thuankkk, Dec 6, 2008 IP
  20. snvc

    snvc Peon

    Messages:
    194
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #20
    Thanks. Might be useful.
     
    snvc, Dec 6, 2008 IP