diff --git a/inc/code/dataCapture.php b/inc/code/dataCapture.php index c5fbd04..9cfd978 100644 --- a/inc/code/dataCapture.php +++ b/inc/code/dataCapture.php @@ -14,7 +14,36 @@ class DataCapture const GOOGLE_SEARCH_ANALYTICS_MAX_DATE_OFFSET = 4; const GOOGLE_SEARCH_ANALYTICS_MAX_DAYS = 90; - + + + /** + * Get authorized sites from Google Search Console + * + * @returns Array Site URL and permission level + */ + public function getSitesGoogleSearchConsole() { + /* Authorize Google via oAuth 2.0 */ + $gapiOauth = new GAPIoAuth(); + $client = $gapiOauth->LogIn(); + + /* Load Google Webmasters API */ + $webmasters = new Google_Service_Webmasters($client); + + /* Load sites functions */ + $siteServices = $webmasters->sites; + + /* Get list of sites */ + $gSites = $siteServices ->listSites(); + + $return = array(); + foreach( $gSites->getSiteEntry() as $site ) { + $return[] = array( 'url' => $site['siteUrl'], 'permission' => $site['permissionLevel'] ); + } + + return $return; + } + + /** * Query database. Retrun all values from a table * diff --git a/inc/html/reportQuickLinks.php b/inc/html/reportQuickLinks.php new file mode 100644 index 0000000..e69de29 diff --git a/index.php b/index.php index 316b568..33887e7 100644 --- a/index.php +++ b/index.php @@ -9,21 +9,20 @@
Configuration file is missing
'; } else { - echo 'Configuration is set. No further action is needed at this time.
'; + echo 'The configuration file is set.
'; } ?>The sites listed here directly correlate to the URL for the site you have configured in Google Search Console. Ensure they match what is entered in Google Search Console.
-Use the checkbox to enable/disable this site from being available to the Data Capture tool.
+Choose which sites you wish to capture data from Google Search Console.
+Not seeing the sites you expect?
Ensure that you have enabled the Google Search Console API and added your Google API Service Account email address as a user to each of your sites in Google Search Console.
Instruction on how to configure Google Search Analytics for API Access