list-interop / convertkit-client
An API Client for ConvertKit
Installs: 7 936
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 4
Requires
- php: ~8.1 || ~8.2
- ext-json: *
- fig/http-message-util: ^1.1
- myclabs/php-enum: ^1.8
- php-http/discovery: ^1.14.3
- psr/container: ^1 || ^2
- psr/http-client: ^1.0
- psr/http-client-implementation: *
- psr/http-factory: ^1.0
- psr/http-message: ^1.1 || ^2.0
- webmozart/assert: ^1.11
Requires (Dev)
- ext-curl: *
- doctrine/coding-standard: ^12.0
- ergebnis/composer-normalize: ^2.31
- laminas/laminas-diactoros: ^3.0.0
- php-http/curl-client: ^2.3
- phpunit/phpunit: ^10.2.2
- psalm/plugin-phpunit: ^0.18.4
- react/child-process: ^0.6.5
- react/http: ^1.9
- roave/security-advisories: dev-latest
- vimeo/psalm: ^5.13.1
Provides
Conflicts
- symfony/options-resolver: <5.3.7
This package is auto-updated.
Last update: 2024-11-14 22:49:41 UTC
README
Introduction
This is an API Client for the ConvertKit mailing list service for PHP versions 8.0 and up
There are several clients available on Packagist, but the main motivation here is being agnostic to the HTTP client in use.
The client uses PSR17 and 18 standards, so you can bring your own preferred libs.
Implemented Features
- Retrieve form by id
- Subscribe to a form (Custom fields are not yet available)
- List and find tags
- Create Tags
- List custom fields
- Crud for custom fields
- Fetch form subscriber
- Other Crud operations for subscribers
- Tagging subscribers post subscribe.
- Stuff regarding webhooks and purchases…
Roadmap
It'd be nice to work up the rest of the available features in the API, but it probably won't happen very quickly, I'm more likely to work on different implementations first to firm up the spec there so that stable releases can be made. Shipping a caching client using a psr cache pool would be handy for those aspects of the API that rarely change. It would also be quite trivial to implement.
Installation
Composer is the only supported installation method…
As previously mentioned, you'll need a PSR-18 HTTP Client first and also PSR-7 and PSR-17 implementations. For example:
composer require php-http/curl-client composer require laminas/laminas-diactoros
You'll then be able to install this with:
composer require list-interop/convertkit-client
Usage
Docs are admittedly thin on the ground.
The lib ships with a PSR11 factory that you can integrate with your container of choice. It falls back to discovery for whatever PSR-7/17/18 stuff that you have installed.
Ultimately, you'll need API Keys to get going, and assuming you can provide the Client
constructor with its required constructor dependencies, you'll be able to start issuing commands and getting results:
Add a subscriber…
use ListInterop\ConvertKit\Client; use ListInterop\ConvertKit\Exception\ApiError; use ListInterop\ConvertKit\Exception\ConvertKitError; use ListInterop\ConvertKit\Exception\RequestFailure; assert($client instanceof Client); $formId = 123; // Retrieve this from the dashboard or by inspecting the forms returned by the api. try { $client->subscribeToForm($formId, 'me@example.com', 'Fred', ['tag 1', 'tag 2']); } catch (RequestFailure $error) { // Network error - can't reach ConvertKit } catch (ApiError $error) { // Something was wrong with the values provided, or your API key was wonky // i.e. The API rejected your request } catch (ConvertKitError $error) { // Generic Error, Assertion failed etc. // All exceptions implement this interface, Providing an invalid email address will get you here. }
You should find that exceptions are consistent and meaningful, but for now, to find out what those are, you'll need to look at the source.
Contributions
Are most welcome, but please make sure that pull requests include relevant tests. There's a handy composer script you can run locally:
composer check
… which will check coding standards, run psalm and phpunit in order.