From 260f1b6153b20214f2834ca1e353b77787637fe8 Mon Sep 17 00:00:00 2001 From: Tim Carr Date: Mon, 6 Mar 2023 15:09:19 +0000 Subject: [PATCH] Specify a User-Agent string in all API requests --- src/ConvertKit_API.php | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/ConvertKit_API.php b/src/ConvertKit_API.php index a816750..b2cf385 100644 --- a/src/ConvertKit_API.php +++ b/src/ConvertKit_API.php @@ -19,6 +19,13 @@ */ class ConvertKit_API { + /** + * The SDK version. + * + * @var string + */ + public const VERSION = '1.0.0'; + /** * ConvertKit API Key * @@ -95,7 +102,15 @@ public function __construct(string $api_key, string $api_secret, bool $debug = f $this->api_key = $api_key; $this->api_secret = $api_secret; $this->debug = $debug; - $this->client = new Client(); + + // Specify a User-Agent for API requests. + $this->client = new Client( + [ + 'headers' => [ + 'User-Agent' => 'ConvertKitPHPSDK/' . self::VERSION . ';PHP/' . phpversion(), + ], + ] + ); if ($debug) { $this->debug_logger = new Logger('ck-debug');