diff --git a/composer.json b/composer.json index 6778b53cc..6fc33cc43 100644 --- a/composer.json +++ b/composer.json @@ -7,7 +7,7 @@ "ext-openssl": "*", "ext-soap": "*", "google/auth": "^1.0.0", - "guzzlehttp/guzzle": "^7.0", + "guzzlehttp/guzzle": "^6.0 || ^7.0", "guzzlehttp/psr7": "^1.2", "monolog/monolog": "^2.2.0", "phpdocumentor/reflection-docblock": "^3.0.3 || ^4.0 || ^5.0", diff --git a/src/Google/AdsApi/Common/AdsHeaderFormatter.php b/src/Google/AdsApi/Common/AdsHeaderFormatter.php index facd9bf97..f8976b993 100644 --- a/src/Google/AdsApi/Common/AdsHeaderFormatter.php +++ b/src/Google/AdsApi/Common/AdsHeaderFormatter.php @@ -118,11 +118,20 @@ private function formatUtilUsages($adsUtilities, $includeUtilityUsage) private function formatGuzzleInfo() { - $guzzleInfoTokens = ['GuzzleHttp/' . ClientInterface::MAJOR_VERSION]; + $guzzleInfoTokens = ['GuzzleHttp/' . $this->getGuzzleVersion()]; if (extension_loaded('curl') && function_exists('curl_version')) { $guzzleInfoTokens[] = 'curl/' . \curl_version()['version']; } return implode(', ', $guzzleInfoTokens); } + + private function getGuzzleVersion() + { + if (defined('GuzzleHttp\ClientInterface::MAJOR_VERSION')) { + return ClientInterface::MAJOR_VERSION; + } + + return ClientInterface::VERSION; + } } diff --git a/tests/Google/AdsApi/AdWords/Reporting/v201809/RequestOptionsFactoryTest.php b/tests/Google/AdsApi/AdWords/Reporting/v201809/RequestOptionsFactoryTest.php index 6ddc19110..5dbb9a082 100644 --- a/tests/Google/AdsApi/AdWords/Reporting/v201809/RequestOptionsFactoryTest.php +++ b/tests/Google/AdsApi/AdWords/Reporting/v201809/RequestOptionsFactoryTest.php @@ -418,11 +418,20 @@ private function getFormattedUserAgent() private function formatGuzzleInfo() { - $guzzleInfoTokens = ['GuzzleHttp/' . ClientInterface::MAJOR_VERSION]; + $guzzleInfoTokens = ['GuzzleHttp/' . $this->getGuzzleVersion()]; if (extension_loaded('curl') && function_exists('curl_version')) { $guzzleInfoTokens[] = 'curl/' . \curl_version()['version']; } return implode(', ', $guzzleInfoTokens); } + + private function getGuzzleVersion() + { + if (defined('GuzzleHttp\ClientInterface::MAJOR_VERSION')) { + return ClientInterface::MAJOR_VERSION; + } + + return ClientInterface::VERSION; + } }