Skip to content

Include User Agent header in API requests #34

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 7, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion src/ConvertKit_API.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@
*/
class ConvertKit_API
{
/**
* The SDK version.
*
* @var string
*/
public const VERSION = '1.0.0';

/**
* ConvertKit API Key
*
Expand Down Expand Up @@ -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');
Expand Down