1- # ConvertKit SDK PHP
1+ # Kit SDK PHP
22
3- The ConvertKit PHP SDK provides convinient access to the ConvertKit API from applications written in the PHP language.
3+ The Kit PHP SDK provides convinient access to the Kit API from applications written in the PHP language.
44
55It includes a pre-defined set of methods for interacting with the API.
66
@@ -10,6 +10,7 @@ It includes a pre-defined set of methods for interacting with the API.
1010| -------------| -------------| --------------------| --------------|
1111| 1.x | v3 | API Key and Secret | 7.4+ |
1212| 2.x | v4 | OAuth | 8.0+ |
13+ | 2.2+ | v4 | API Key | 8.0+ |
1314
1415Refer to [ this guide] ( MIGRATION.md ) for changes when upgrading to the v2 SDK.
1516
@@ -41,9 +42,9 @@ If you use Composer, these dependencies should be handled automatically.
4142
4243### 2.x (v4 API, OAuth, PHP 8.0+)
4344
44- First, register your OAuth application in the ` OAuth Applications ` section at https://app.convertkit .com/account_settings/advanced_settings .
45+ First, register your OAuth application in the ` OAuth Applications ` section at https://app.kit .com/account_settings/advanced_settings .
4546
46- Using the supplied Client ID and secret, redirect the user to ConvertKit to grant your application access to their ConvertKit account.
47+ Using the supplied Client ID and secret, redirect the user to Kit to grant your application access to their Kit account.
4748
4849``` php
4950// Require the autoloader (if you're using a PHP framework, this may already be done for you).
@@ -59,7 +60,7 @@ $api = new \ConvertKit_API\ConvertKit_API(
5960header('Location: '.$api->get_oauth_url('<your _redirect_uri >'));
6061```
6162
62- Once the user grants your application access to their ConvertKit account, they'll be redirected to your Redirect URI with an authorization code. For example:
63+ Once the user grants your application access to their Kit account, they'll be redirected to your Redirect URI with an authorization code. For example:
6364
6465` your-redirect-uri?code=<auth_code> `
6566
@@ -118,26 +119,40 @@ $api = new \ConvertKit_API\ConvertKit_API(
118119API requests may then be performed:
119120
120121``` php
121- $result = $api->add_subscriber_to_form(12345, 'joe.bloggs@convertkit .com');
122+ $result = $api->add_subscriber_to_form(12345, 'joe.bloggs@kit .com');
122123```
123124
124125To determine whether a new entity / relationship was created, or an existing entity / relationship updated, inspect the HTTP code of the last request:
125126
126127``` php
127- $result = $api->add_subscriber_to_form(12345, 'joe.bloggs@convertkit .com');
128+ $result = $api->add_subscriber_to_form(12345, 'joe.bloggs@kit .com');
128129$code = $api->getResponseInterface()->getStatusCode(); // 200 OK if e.g. a subscriber already added to the specified form, 201 Created if the subscriber added to the specified form for the first time.
129130```
130131
131132The PSR-7 response can be fetched and further inspected, if required - for example, to check if a header exists:
132133
133134``` php
134- $result = $api->add_subscriber_to_form(12345, 'joe.bloggs@convertkit .com');
135+ $result = $api->add_subscriber_to_form(12345, 'joe.bloggs@kit .com');
135136$api->getResponseInterface()->hasHeader('Content-Length'); // Check if the last API request included a `Content-Length` header
136137```
137138
139+ ### 2.2+ (v4 API, API Key, PHP 8.0+)
140+
141+ Get your Kit API Key and API Secret [ here] ( https://app.kit.com/account_settings/developer_settings ) and set it somewhere in your application.
142+
143+ ``` php
144+ // Require the autoloader (if you're using a PHP framework, this may already be done for you).
145+ require_once 'vendor/autoload.php';
146+
147+ // Initialize the API class.
148+ $api = new \ConvertKit_API\ConvertKit_API(
149+ apiKey: '<your _v4_api_key >'
150+ );
151+ ```
152+
138153### 1.x (v3 API, API Key and Secret, PHP 7.4+)
139154
140- Get your ConvertKit API Key and API Secret [ here] ( https://app.convertkit .com/account/edit ) and set it somewhere in your application.
155+ Get your Kit API Key and API Secret [ here] ( https://app.kit .com/account_settings/developer_settings ) and set it somewhere in your application.
141156
142157``` php
143158// Require the autoloader (if you're using a PHP framework, this may already be done for you).
@@ -149,7 +164,7 @@ $api = new \ConvertKit_API\ConvertKit_API('<your_public_api_key>', '<your_secret
149164
150165## Handling Errors
151166
152- The ConvertKit PHP SDK uses Guzzle for all HTTP API requests. Errors will be thrown as Guzzle's ` ClientException ` (for 4xx errors),
167+ The Kit PHP SDK uses Guzzle for all HTTP API requests. Errors will be thrown as Guzzle's ` ClientException ` (for 4xx errors),
153168or ` ServerException ` (for 5xx errors).
154169
155170``` php
@@ -190,4 +205,4 @@ See the [PHP SDK docs](./docs/classes/ConvertKit_API/ConvertKit_API.md)
190205
191206See our [ contributor guide] ( CONTRIBUTING.md ) for setting up your development environment, testing and submitting a PR.
192207
193- For ConvertKit , refer to the [ deployment guide] ( DEPLOYMENT.md ) on how to publish a new release.
208+ For Kit , refer to the [ deployment guide] ( DEPLOYMENT.md ) on how to publish a new release.
0 commit comments