定制 sammakescode/klaviyo-api 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

sammakescode/klaviyo-api

最新稳定版本:2.0.0

Composer 安装命令:

composer require sammakescode/klaviyo-api

包简介

A Klaviyo library for PHP written by a normal person

README 文档

README

Klaviyo's PHP library seems like it was assembled on a computer without a monitor, doesn't it? Here, I've created a rudimentary layer on top of Guzzle to provide a more sensible experience.

Requirements

  • PHP 8.2 or later
  • Composer

Installation

composer require sammakescode/klaviyo-api

Example

This section will give you an example. Check out the Wiki for more detailed information.

Sending an Event

We can send an event for an anonymous user like this.

    use \SamMakesCode\KlaviyoApi\KlaviyoApi;
    use \SamMakesCode\KlaviyoApi\Objects\Metric;
    use \SamMakesCode\KlaviyoApi\Objects\Profile;

    $client = new KlaviyoApi('your-api-key');
    $client->events()->create(Event::make(
        [
            'properties' => [
                'custom_property' => 'Why, yes!',
            ],
        ],
        Metric::make('Created Account'),
        Profile::make([
            'email' => 'john@example.org',
        ])
    ));

Laravel

The library works perfectly well with Laravel, but you'll need to set up a service provider for it.

<?php

namespace App\Providers;

use Illuminate\Support\ServiceProvider;
use SamMakescode\KlaviyoApi\KlaviyoApi;

class KlaviyoServiceProvider extends ServiceProvider
{
    public function register(): void
    {
        $this->app->singleton(KlaviyoApi::class, function () {
            return new KlaviyoApi(
                env('KLAVIYO_API_KEY'),
            );
        });
    }
}

Don't for get to add your API key to your .env file.

Contributions

Contribution and issues are welcome.

统计信息

  • 总下载量: 22
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-07-11