public function validate_api_url() {

		$index = @file_get_contents( $this->api_url );

		// check for HTTP 404 response (file_get_contents() returns false when encountering 404)
		// this usually means:
		// 1) the store URL is not correct (missing sub-directory path, etc)
		// 2) pretty permalinks are disabled
		if ( false === $index ) {
			throw new WC_API_Client_Exception( sprintf( 'Invalid URL, no WC API found at %s -- ensure your store URL is correct and pretty permalinks are enabled.', $this->api_url ), 404 );
		}

		// older versions of WC (2.0 and under) will simply return a "1"
		if ( '1' === $index ) {
			throw new WC_API_Client_Exception( sprintf( 'Please upgrade the WooCommerce version on %s to v2.2 or greater.', $this->api_url ) );
		}

		// strip invalid leading/trailing characters from JSON
		$json_start = strpos( $index, '{' );
		$json_end = strrpos( $index, '}' ) + 1; // inclusive

		$index = json_decode( substr( $index, $json_start, ( $json_end - $json_start ) ) );

		// check for invalid JSON, an error here usually means:
		// 1) there's some garbage in the JSON output, WP Super Cache is notorious for adding an HTML comment to non-cached pages
		if ( null === $index ) {
			throw new WC_API_Client_Exception( sprintf( 'WC API found, but JSON is corrupt -- ensure the index at %s is valid JSON.', $this->api_url ) );
		}

		// check if the site URL returned is SSL, but SSL is not enabled
		if ( 'https' === parse_url( $index->store->URL, PHP_URL_SCHEME ) && ! $index->store->meta->ssl_enabled ) {

			// override the user-entered URL with the SSL version
			$this->api_url = str_replace( 'http://', 'https://', $this->api_url );
		}
	}