项目作者: Th3Mouk

项目描述 :
PHP client to send Klaviyo events with Reactive Programming paradigm
高级语言: PHP
项目地址: git://github.com/Th3Mouk/reactive-klaviyo.git
创建时间: 2019-06-05T08:56:26Z
项目社区:https://github.com/Th3Mouk/reactive-klaviyo

开源协议:MIT License

下载


Klaviyo HttpClient

This PHP library provide a simple way to send events to Klaviyo API.
This implementation is based on an asynch HttpClient
that use Reactive Programming paradigm.

Latest Stable Version
Latest Unstable Version
Total Downloads
License

Build Status
Scrutinizer Code Quality

Installation

composer require th3mouk/reactive-klaviyo

Basic usage

Create an instance of HttpClient

  1. use Clue\React\Buzz\Browser as ClueBrowser;
  2. use Rxnet\HttpClient\Browser as RxBrowser;
  3. $clue = new ClueBrowser(EventLoop::getLoop());
  4. $httpClient = new RxBrowser($clue);

Instantiate Klaviyo Client

  1. $client = new Client('klaviyo-api-token', $httpClient);

Create a payload

According to Klaviyo documentation, the payload
must be base64 encoded.
This library use fluent setters to ease its creation and enforce typing with a
Property class.

  1. $payload = Payload::create('event-name')
  2. ->addCustomerProperty(Property::create('$email', 'polo@klaviyo.com'))
  3. ->addCustomerProperty(Property::create('$id', 'uuid-or-whatever'))
  4. ->addProperty(Property::create('lang', 'fr'))
  5. ->addProperty(Property::create('amount', 56))
  6. ->definePastEventDate(1559722012)
  7. ;

Send

Two methods are available, the same that in documentation.

  1. $client->track(Payload $payload)
  2. $client->trackOnce(Payload $payload)

Please

Feel free to improve this library.