public function getAlexa()
 {
     try {
         $seostats = new SEOstats();
         if ($seostats->setUrl($this->url)) {
             return Alexa::getGlobalRank();
         }
     } catch (Exception $e) {
         $e->getMessage();
     }
 }
Exemple #2
0
 $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;
     //}
Exemple #3
0
    // Bind the URL to the current SEOstats instance.
    if ($seostats->setUrl($url)) {
        /**
         *  Print HTML code for the 'daily traffic trend'-graph.
         */
        echo Alexa::getTrafficGraph(1);
        /**
         *  Print HTML code for the 'daily pageviews (percent)'-graph.
         */
        echo Alexa::getTrafficGraph(2);
        /**
         *  Print HTML code for the 'daily pageviews per user'-graph.
         */
        echo Alexa::getTrafficGraph(3);
        /**
         *  Print HTML code for the 'time on site (in minutes)'-graph.
         */
        echo Alexa::getTrafficGraph(4);
        /**
         *  Print HTML code for the 'bounce rate (percent)'-graph.
         */
        echo Alexa::getTrafficGraph(5);
        /**
         *  Print HTML code for the 'search visits'-graph, using
         *  specific graph dimensions of 320*240 px.
         */
        echo Alexa::getTrafficGraph(6, false, 320, 240);
    }
} catch (\Exception $e) {
    echo 'Caught SEOstatsException: ' . $e->getMessage();
}
//
// 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();
}