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.

Display # of Backlinks from Google Webmaster

Discussion in 'Google API' started by Cyber Wizard, Oct 12, 2010.

  1. #1
    As many of you know, Google Webmaster will show you the number of backlinks there are to your website. However, does anyone know if there is a script that uses Google's API so that I can show that number somewhere on my website?

    Please and thank you ;)
     
    Cyber Wizard, Oct 12, 2010 IP
  2. seo_tampa

    seo_tampa Greenhorn

    Messages:
    29
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    16
    #2
    good question - I would be interested to get something like that too
     
    seo_tampa, Oct 15, 2010 IP
  3. Sumitthewriter

    Sumitthewriter Guest

    Messages:
    43
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    NO there is no such API. Google Periodically updates number of links for your websites and these is no such calculator or API, many back link watch sites however can do a little help...
     
    Sumitthewriter, Oct 16, 2010 IP
  4. Pramono Tunggul

    Pramono Tunggul Member

    Messages:
    92
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    41
    #4
    I'm curious about that too. Many sites can display that kind of information, that must be a way to do this. anyone?
     
    Pramono Tunggul, Oct 18, 2010 IP
  5. kinah

    kinah Guest

    Messages:
    64
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #5
    I would be interested to get something like that too .
     
    kinah, Nov 17, 2010 IP
  6. maruf22

    maruf22 Peon

    Messages:
    45
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    <?php
    /**
    * Backlink Checker Tool for checking the existance of backlinks
    * on a certain website. See Documentation for more information.
    *
    *
    * LICENSE:
    * --------
    * This program is free software; you can redistribute it and/or modify it
    * under the terms of the GNU General Public License as published by the
    * Free Software Foundation; either version 2 of the License, or (at your
    * option) any later version.
    *
    * This program is distributed in the hope that it will be useful, but
    * WITHOUT ANY WARRANTY; without even the implied warranty of
    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
    * Public License for more details.
    *
    * You should have received a copy of the GNU General Public License along
    * with this program; if not, write to the
    *
    * Free Software Foundation, Inc.,
    * 59 Temple Place, Suite 330,
    * Boston, MA 02111-1307, USA.
    * ------------------------------------------------------------------------
    */

    // The Backlink-Checker class
    class BacklinkChecker {
    protected $SQLUSER = "";
    protected $SQLPASS = "";
    protected $SQLSERV = "localhost";
    protected $SQLDB = "";
    protected $sqlConn = NULL;
    protected $sqlDb = NULL;

    protected $SLEEPTIME = 1800;
    private $backlinks = array();
    private $backlinkCount = 0;
    private $stat_rounds = 1;

    // Constructor
    function BacklinkChecker() {
    // Set SQL connection, if not already done
    if( $this->sqlConn === NULL ) {
    $this->sqlConn = mysql_connect($this->SQLSERV, $this->SQLUSER, $this->SQLPASS);
    if( $this->sqlConn === FALSE ) {
    Error(mysql_error());
    } else {
    $this->sqlDb = mysql_select_db($this->SQLDB);
    if( $this->sqlDb === FALSE ) {
    Error(mysql_error);
    }
    }
    }
    // Load all backlinks
    $this->loadBacklinks();
    $this->Run();
    }

    /*
    * Get all backlinks from a database
    * @return associative array with the data
    */
    protected function loadBacklinks() {
    $this->backlinks = array();
    $res = mysql_query("SELECT * FROM `links`;", $this->sqlConn);
    if( !$res ) {
    Error(mysql_error());
    }

    while( $data = mysql_fetch_assoc($res) ) {
    $this->backlinks[] = $data;
    }
    $this->backlinkCount = sizeof($this->backlinks);
    }

    // General main loop
    protected function Run() {
    if( $this->backlinkCount > 0 ) {
    for(;;) {
    echo 'Round ',$this->stat_rounds,"...\n";
    $this->loadBacklinks();

    foreach($this->backlinks as $bl) {
    echo 'Checking ',$bl['url']," on ",$bl['host'],"... ";
    $buf = "";
    $buf = file_get_contents($bl['host']);

    if( strlen($buf) <= 0 ) {
    echo "FAILED - Got no data!\n";
    $query = "UPDATE `links` SET `active`=0, `lastupdate`='".time()."' WHERE `url`='".$bl['url']."' AND `host`='".$bl['host']."';";
    if( !mysql_query($query) ) {
    Error(mysql_error());
    }
    } else {
    $matches = array();
    // TODO better regex for url
    $s = array("/","-");
    $r = array("\/","\-");
    $url = str_replace($s,$r,$bl['url']);
    preg_match("/.*<a.*href=\"($url).*\".*>.*/", $buf, $matches);
    if( strlen($matches[1]) <= 0 ) {
    echo "FAILED - Not found!\n";
    $query = "UPDATE `links` SET `active`=0, `lastupdate`='".time()."' WHERE `url`='".$bl['url']."' AND `host`='".$bl['host']."';";
    if( !mysql_query($query) ) {
    Error(mysql_error());
    }
    } else {
    echo "CHECK!\n";
    $query = "UPDATE `links` SET `lastseen`='".time()."', `active`=1, `lastupdate`='".time()."' WHERE `url`='".$bl['url']."' AND `host`='".$bl['host']."';";
    if( !mysql_query($query) ) {
    Error(mysql_error());
    }
    }
    }
    }
    $this->printStats();
    $this->stat_rounds++;
    sleep($this->SLEEPTIME);
    }
    }
    }

    // Statistics
    protected function printStats() {
    echo "Stats:\n------\nRound: ",$this->stat_rounds,"\nBacklinks: ",$this->backlinkCount,"\n\n";
    }

    // Public function to Quit
    public function Quit() {
    if($this->sqlConn != NULL ) {
    mysql_close($this->sqlConn);
    }
    exit(0);
    }

    // Private error function
    private function Error($message) {
    if( $this->sqlConn != NULL ) {
    mysql_close($this->sqlConn);
    }
    echo "Error: $message!\n";
    exit(1);
    }
    };


    ##### START #####
    $blChecker = new BacklinkChecker();
    $blChecker->Quit();
    ?>


    Check this code,it may help you.
     
    maruf22, Nov 29, 2010 IP