diff --git a/SEOstats/Config/ApiKeys.php b/SEOstats/Config/ApiKeys.php index b0d5e1cd..54ccbf75 100644 --- a/SEOstats/Config/ApiKeys.php +++ b/SEOstats/Config/ApiKeys.php @@ -32,22 +32,34 @@ class ApiKeys // To acquire a SISTRIX API key, visit: // http://www.sistrix.de const SISTRIX_API_ACCESS_KEY = ''; + // + public static function env($config, $default) + { + $dotenv = new \Dotenv\Dotenv(__DIR__."/../../../../../"); + $dotenv->load(); + $config_value = getenv($config); + if(is_string($config_value) && (strlen(trim($config_value)) > 0)) { + return $config_value; + } else { + return $default; + } + } public static function getGoogleSimpleApiAccessKey() { - return env('GOOGLE_SIMPLE_API_ACCESS_KEY', self::GOOGLE_SIMPLE_API_ACCESS_KEY); + return self::env('GOOGLE_SIMPLE_API_ACCESS_KEY', self::GOOGLE_SIMPLE_API_ACCESS_KEY); } public static function getMozscapeAccessId() { - return env('MOZSCAPE_ACCESS_ID', self::MOZSCAPE_ACCESS_ID); + return self::env('MOZSCAPE_ACCESS_ID', self::MOZSCAPE_ACCESS_ID); } public static function getMozscapeSecretKey() { - return env('MOZSCAPE_SECRET_KEY', self::MOZSCAPE_SECRET_KEY); + return self::env('MOZSCAPE_SECRET_KEY', self::MOZSCAPE_SECRET_KEY); } public static function getSistrixApiAccessKey() { - return env('SISTRIX_API_ACCESS_KEY', self::SISTRIX_API_ACCESS_KEY); + return self::env('SISTRIX_API_ACCESS_KEY', self::SISTRIX_API_ACCESS_KEY); } } diff --git a/example/get-alexa-metrics.php b/example/get-alexa-metrics.php index a082af6a..a2045bd9 100644 --- a/example/get-alexa-metrics.php +++ b/example/get-alexa-metrics.php @@ -59,6 +59,31 @@ // Get Alexa's page load time info for the given domain. echo "Page load time: " . Alexa::getPageLoadTime() . PHP_EOL; + + //Get bounce Rate for the Given domain from alexa + echo "Bounce Rate: " . + Alexa::getBounceRate() . PHP_EOL; + + //Get Daily page views per user for the given domain provided by alexa + echo "Daily page views per user: " . + Alexa::getDailyPageViews() . PHP_EOL; + + //Get Daily time on site for the Given domain from alexa + echo "Daily time on site: " . + Alexa::getDailyTimeOnSite() . PHP_EOL; + + //Get search visits for the given domain provided by alexa + echo "Search Visits: " . + Alexa::getSearchVisits() . PHP_EOL; + + //Get Top keywords for the Given domain from alexa + echo "Top keywords : "; + print_r(Alexa::getKeyWords()) . PHP_EOL; + + //Get search visits for the given domain provided by alexa + echo "Top Visitor Countries: "; + print_r(Alexa::getVisitorCountries()) . PHP_EOL; + } } catch (\Exception $e) {