surefirejack/convertkit

dev-master 2020-11-26 15:26 UTC

This package is auto-updated.

Last update: 2024-09-26 23:40:21 UTC


README

这是与 ConvertKit API 一起使用的 (非官方) ConvertKit SDK

我们创建这个 SDK 是为了与我们的软件 Deadline Funnel (https://deadlinefunnel.com) 进行 API 集成。

安装

直接下载并包含,或者通过 Composer 安装

composer require surefirejack/convertkit

发送一个简单的请求

使用以下方式创建一个新的 ConvertKit 对象

  1. 您的用户 API 密钥
  2. 您的用户 API 密钥
require_once __DIR__.'/vendor/autoload.php';

use ConvertKit\ConvertKit;

$apiKey = 'api-key-here';
$apiSecretKey = 'api-secret-key-here';

$ck = new ConvertKit($apiKey, $apiSecretKey);

列出所有序列

$sequences = $ck->sequence();
$response = $sequences->showall();
print_r($response);

列出所有订阅者

$subscriber = $ck->subscriber();
$response = $subscriber->showall();
print_r($response);

// Show the details of the first subscriber returned
$firstName = $response->subscribers[0]->first_name;
$email = $response->subscribers[0]->email_address;
$fieldsObject = $response->subscribers[0]->fields;

查看特定订阅者的详细信息

$subscriberId = 123456;
$response = $ck->subscriber($subscriberId)->view();
print_r($response);

更新订阅者的自定义字段

$subscriberId = 123456;
$customFields = array(
  'fields' => array(
      'deadlinetext' => 'Jan 22 2018'
  )
);

$response = $ck->subscriber($subscriberId)->update($customFields);


print_r($response);

查看所有表单

$response = $ck->form()->showall();
print_r($response);

查看所有自定义字段

$response = $ck->customfield()->showall();
print_r($response);

删除自定义字段

$customFieldId = 567;

$customfield = $ck->customfield();
$response = $customfield->delete($customFieldId);

print_r($response);

添加 webhook

// Register a webhook to be pinged when a subscriber recieves a tag
$tagId = 789;
$webhookUrl = "http://example.com/incoming";

$params = array(
    "target_url" => $webhookUrl,
    "event" => array(
        'name' => 'subscriber.tag_add',
        'tag_id'=> $tagId
    )

);

$webhook = $ck->webhook();
$response = $webhook->add($params);
print_r($response);