public function getAlexa()
 {
     try {
         $seostats = new SEOstats();
         if ($seostats->setUrl($this->url)) {
             return Alexa::getGlobalRank();
         }
     } catch (Exception $e) {
         $e->getMessage();
     }
 }
Exemple #2
0
 $link_num = str_replace(",", "", $row[1]);
 $linked_pages = $row[2];
 // Bind the URL to the current SEOstats instance.
 if ($seostats->setUrl($url)) {
     //-------------------------------------------------------------------------------------------------------------------------------|
     //-----if you start getting a bunch of 0's or NA's, remember that there are pretty low limits to Alexa and Google calls...-------|
     //-------------------------------------------------------------------------------------------------------------------------------|
     $alexa = SEOstats\Alexa::getGlobalRank();
     $pagerank = SEOstats\Google::getPageRank();
     $g_links = SEOstats\Google::getBacklinksTotal("www." . $row[0]);
     $g_links_no_www = SEOstats\Google::getBacklinksTotal($row[0]);
     $g_plus_count = SEOstats\Social::getGooglePlusShares();
     $twitter_shares = SEOstats\Social::getTwitterShares();
     $linkedin_shares = SEOstats\Social::getLinkedInShares();
     echo "<div class='row'><div class='col-md-12'><h3>" . $row[0] . "</h3>";
     echo "<div class='row'><div class='col-md-7'>Alexa rank = " . SEOstats\Alexa::getGlobalRank() . "<br />";
     echo "Daily traffic graph: " . SEOstats\Alexa::getTrafficGraph(1) . "<br /></div>";
     echo "<div class='col-md-3'>PageRank = " . SEOstats\Google::getPageRank() . "<br />";
     echo "Google links = " . SEOstats\Google::getBacklinksTotal("www." . $row[0]) . "<br />";
     echo "Google links (no www) = " . SEOstats\Google::getBacklinksTotal($row[0]) . "<br />";
     echo "Twitter shares: " . SEOstats\Social::getTwitterShares() . "<br />";
     echo "Plus ones: " . SEOstats\Social::getGooglePlusShares() . "<br />";
     echo "Twitter shares: " . SEOstats\Social::getTwitterShares() . "<br />";
     echo "Linkedin shares: " . SEOstats\Social::getLinkedInShares() . "<br /><br /></div>";
     echo "<div class='col-md-3'>SEMRush Search Engine Traffic Graph: " . SEOstats\SemRush::getDomainGraph(1) . "<br /></div></div></div></div>";
     //----------------------------------------------------------------------------------------|
     //--------------------uncomment this stuff when you want to insert into MySQL!!-----------|
     //----------------------------------------------------------------------------------------|
     /* Prepared statement, stage 1: prepare */
     //if (!($stmt = $mysqli->prepare("INSERT INTO seo (url, alexa, pagerank, link_num, linked_pages, g_links, g_links_no_www, g_plus_ones, linkedin_shares) VALUES (?,?,?,?,?,?,?,?)"))) {
     //	 echo "Prepare failed: (" . $mysqli->errno . ") " . $mysqli->error;
// 2. Copy this example file (and the others) from ./example/example.php to ./example.php
//
// For further reference see: https://github.com/eyecatchup/SEOstats/issues/49
// Bootstrap the library / register autoloader
#require_once realpath(__DIR__ . '/SEOstats/bootstrap.php');
require_once realpath(__DIR__ . '/vendor/autoload.php');
use SEOstats\Services\Alexa;
try {
    $url = testURL;
    // Create a new SEOstats instance.
    $seostats = new \SEOstats\SEOstats();
    // Bind the URL to the current SEOstats instance.
    if ($seostats->setUrl($url)) {
        print "Alexa metrics for " . $url . PHP_EOL;
        // Get the global Alexa Traffic Rank (last 3 months).
        print "Global Rank:      " . Alexa::getGlobalRank() . PHP_EOL;
        // Get the country-specific Alexa Traffic Rank.
        print "Country Rank:     ";
        $countryRank = Alexa::getCountryRank();
        if (is_array($countryRank)) {
            print $countryRank['rank'] . ' (in ' . $countryRank['country'] . ")" . PHP_EOL;
        } else {
            print "{$countryRank}\r\n";
        }
        // Get Alexa's backlink count for the given domain.
        print "Total Backlinks:  " . Alexa::getBacklinkCount() . PHP_EOL;
        // Get Alexa's page load time info for the given domain.
        print "Page load time:   " . Alexa::getPageLoadTime() . PHP_EOL;
    }
} catch (\Exception $e) {
    print 'Caught SEOstatsException: ' . $e->getMessage();
Exemple #4
0
// 2. Copy this example file (and the others) from ./example/example.php to ./example.php
//
// For further reference see: https://github.com/eyecatchup/SEOstats/issues/49
// Bootstrap the library / register autoloader
#require_once realpath(__DIR__ . '/SEOstats/bootstrap.php');
require_once realpath(__DIR__ . '/vendor/autoload.php');
use SEOstats\Services\Alexa;
try {
    $url = 'http://www.google.de/';
    // Create a new SEOstats instance.
    $seostats = new \SEOstats\SEOstats();
    // Bind the URL to the current SEOstats instance.
    if ($seostats->setUrl($url)) {
        echo "Alexa metrics for " . $url . PHP_EOL;
        // Get the global Alexa Traffic Rank (last 3 months).
        echo "Global Rank:      " . Alexa::getGlobalRank() . PHP_EOL;
        // Get the country-specific Alexa Traffic Rank.
        echo "Country Rank:     ";
        $countryRank = Alexa::getCountryRank();
        if (is_array($countryRank)) {
            echo $countryRank['rank'] . ' (in ' . $countryRank['country'] . ")" . PHP_EOL;
        } else {
            echo "{$countryRank}\r\n";
        }
        // Get Alexa's backlink count for the given domain.
        echo "Total Backlinks:  " . Alexa::getBacklinkCount() . PHP_EOL;
        // Get Alexa's page load time info for the given domain.
        echo "Page load time:   " . Alexa::getPageLoadTime() . PHP_EOL;
    }
} catch (\Exception $e) {
    echo 'Caught SEOstatsException: ' . $e->getMessage();