//
// 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();
}