A PHP API client for ConvertKit

Overview

ConvertKit PHP API Client

Build Status

codecov Psalm Type Coverage

Latest Stable Version Total Downloads

Introduction

This is an API Client for the ConvertKit mailing list service for PHP versions 7.4 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, '[email protected]', '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.

License

MIT Licensed.

Comments
Releases(0.3.0)
  • 0.3.0(Nov 4, 2022)

  • 0.2.0(Aug 29, 2022)

    What's Changed

    • Bump ridedott/merge-me-action from 2.9.152 to 2.9.153 by @dependabot in https://github.com/list-interop/convertkit-client/pull/3
    • Bump php-http/discovery from 1.14.1 to 1.14.2 by @dependabot in https://github.com/list-interop/convertkit-client/pull/7
    • Bump laminas/laminas-diactoros from 2.10.0 to 2.11.0 by @dependabot in https://github.com/list-interop/convertkit-client/pull/5
    • Bump webmozart/assert from 1.10.0 to 1.11.0 by @dependabot in https://github.com/list-interop/convertkit-client/pull/9
    • Bump phpunit/phpunit from 9.5.20 to 9.5.21 by @dependabot in https://github.com/list-interop/convertkit-client/pull/11
    • Bump psalm/plugin-phpunit from 0.16.1 to 0.17.0 by @dependabot in https://github.com/list-interop/convertkit-client/pull/10
    • Bump myclabs/php-enum from 1.8.3 to 1.8.4 by @dependabot in https://github.com/list-interop/convertkit-client/pull/21
    • Bump vimeo/psalm from 4.23.0 to 4.26.0 by @dependabot in https://github.com/list-interop/convertkit-client/pull/20
    • Bump php-http/discovery from 1.14.2 to 1.14.3 by @dependabot in https://github.com/list-interop/convertkit-client/pull/17
    • Bump laminas/laminas-diactoros from 2.11.0 to 2.14.0 by @dependabot in https://github.com/list-interop/convertkit-client/pull/19
    • Bump phpunit/phpunit from 9.5.21 to 9.5.23 by @dependabot in https://github.com/list-interop/convertkit-client/pull/23
    • Update Doctrine Coding Standard to ^10.0 by @gsteel in https://github.com/list-interop/convertkit-client/pull/27
    • Drop support for PHP 7.3 by @gsteel in https://github.com/list-interop/convertkit-client/pull/28

    Full Changelog: https://github.com/list-interop/convertkit-client/compare/0.1.0...0.2.0

    Source code(tar.gz)
    Source code(zip)
  • 0.1.0(May 5, 2022)

    Initial Release

    Includes the bare minimum to get email addresses subscribed to an existing "Form"

    What's Changed

    • Bump ridedott/merge-me-action from 2.9.149 to 2.9.152 by @dependabot in https://github.com/list-interop/convertkit-client/pull/1
    • Enable composer require check in CI by @gsteel in https://github.com/list-interop/convertkit-client/pull/2

    New Contributors

    • @dependabot made their first contribution in https://github.com/list-interop/convertkit-client/pull/1
    • @gsteel made their first contribution in https://github.com/list-interop/convertkit-client/pull/2

    Full Changelog: https://github.com/list-interop/convertkit-client/commits/0.1.0

    Source code(tar.gz)
    Source code(zip)
Owner
null
PHP client library for Coveralls API.

php-coveralls PHP client library for Coveralls. Prerequisites PHP 5.5+ for 2.x or 5.3+ for 1.x On GitHub Building on Travis CI, CircleCI, Jenkins or C

null 514 Dec 25, 2022
Enterprise isEven API Client

zonuexe\isEvenApi This package is a modern, high performance, high modularity and strongly static typed enterprise quality API Client of isEven API fo

USAMI Kenta 3 Aug 26, 2021
This document provides the details related to Remittance API. This APIs is used to initiate payment request from Mobile client/others exchange house.

City Bank Remittance API This is where your description should go. Limit it to a paragraph or two. Consider adding a small example. Installation You c

MD ARIFUL HAQUE 2 Oct 2, 2022
A GETTR.com client library written in PHP with Laravel support.

Gettr API Clinet PHP A GETTR.com client library written in PHP with Laravel support. This library uses unofficial publicly accessible API endpoints of

null 10 Dec 13, 2022
SendCloud client for PHP

SendCloud client for PHP Installation composer require guangda/sendcloud Example $mailData = [ 'to'=>'[email protected]', 'subject'=>'test',

Guangda 3 Aug 27, 2021
Bearer client for the PHP programming language

Bearer PHP Client This is the official PHP client for interacting with Bearer.sh. Installation Install the package by running: composer require bearer

Bearer 9 Oct 31, 2022
The most widely used PHP client for RabbitMQ

php-amqplib This library is a pure PHP implementation of the AMQP 0-9-1 protocol. It's been tested against RabbitMQ. The library was used for the PHP

php-amqplib 4.2k Jan 3, 2023
kafka php client

Kafka-php 中文文档 Kafka-php is a pure PHP kafka client that currently supports greater than 0.8.x version of Kafka, this project v0.2.x and v0.1.x are in

Weibo Ad Platform Open Source 1.4k Jan 5, 2023
Artax is an asynchronous HTTP client for PHP based on Amp

Artax is an asynchronous HTTP client for PHP based on Amp. Its API simplifies standards-compliant HTTP resource traversal and RESTful web service consumption without obscuring the underlying protocol. The library manually implements HTTP over TCP sockets; as such it has no dependency on ext/curl.

AMPHP 21 Dec 14, 2022
Grpc go-server php-client

Grpc go-server php-client

凯 1 Jan 24, 2022
Idiomatic PHP client for Google Compute.

Google Compute for PHP Idiomatic PHP client for Google Compute. API Documentation NOTE: This repository is part of Google Cloud PHP. Any support reque

Google APIs 3 Jun 13, 2022
An unofficial EdgeDB PHP client.

Unofficial EdgeDB HTTP PHP client Requirements PHP >= 8.0 (with fileinfo and mbstring) An EdgeDB server instance (tested with 1.0+9ecadfc) Quickstart

T3d 7 Aug 18, 2022
A standalone Amazon S3 (REST) client for PHP 5/CURL

Amazon S3 PHP Class Usage OO method (e,g; $s3->getObject(...)): $s3 = new S3($awsAccessKey, $awsSecretKey); Statically (e,g; S3::getObject(...)): S3::

Donovan Schönknecht 1k Jan 3, 2023
A PHP implementation of RabbitMQ Client for webman plugin.

workbunny/webman-rabbitmq ?? A PHP implementation of RabbitMQ Client for webman plugin. ?? A PHP implementation of RabbitMQ Client for webman plugin 常

workbunny 15 Dec 15, 2022
PHP DataDog StatsD Client

PHP DataDog StatsD Client This is an extremely simple PHP DogStatsD client. Requires PHP >= 5.6.0. See CHANGELOG.md for changes. For a Laravel-specifi

Datadog, Inc. 175 Nov 28, 2022
A PHP MySQL database client class to simplify database access

This lightweight database class is written with PHP and uses the MySQLi extension, it uses prepared statements to properly secure your queries, no need to worry about SQL injection attacks.

Khader Handal 50 Jul 30, 2022
Idiomatic PHP client for Cloud Firestore.

Cloud Firestore for PHP Idiomatic PHP client for Cloud Firestore. API documentation NOTE: This repository is part of Google Cloud PHP. Any support req

Google APIs 151 Dec 10, 2022
Idiomatic PHP client for Memorystore for Memcached.

Memorystore for Memcached for PHP Idiomatic PHP client for Memorystore for Memcached. API documentation NOTE: This repository is part of Google Cloud

Google APIs 1 Mar 20, 2022
Code to accompany the YouTube video "Full PHP cURL API tutorial - how to use a REST API from PHP using cURL"

PHP cURL CRUD Example Example code to accompany this YouTube video. Note that the init_curl.php file contains a placeholder for an API key. DO NOT che

Dave Hollingworth 14 Dec 24, 2022