sendx/sendx-api-php

1.0.0 2024-03-16 15:50 UTC

This package is not auto-updated.

Last update: 2024-09-29 15:38:16 UTC


README

SendX REST API 有两种方法

识别 API 方法

识别 API 方法用于将数据附加到访客。如果尚未创建联系人,我们将创建联系人。如果联系人已存在,则更新它。

示例请求

{
  email: "john.doe@gmail.com",  
  firstName: "John",
  lastName: "Doe",
  birthday: "1989-03-03",
  customFields: { "Designation": "Software Engineer", "Age": "27", "Experience": "5"},  
  tags: ["Developer", "API Team"],  
 }

注意,标签是字符串数组。如果它们之前不存在,API 将创建它们并将它们与联系人关联。

类似地,如果自定义字段不存在,则首先创建该字段并将其与联系人及其对应值关联。如果自定义字段已存在,则仅更新该联系人的值。

我们不会根据识别调用删除任何属性。这意味着,如果您为同一联系人执行了两个 API 调用,例如

API 调用 A

{
   email: "john.doe@gmail.com", 
   firstName: "John",
   birthday: "1989-03-03",
   customFields: { "Designation": "Software Engineer"},  
   tags: ["Developer"],  
}

API 调用 B

{  
  email: "john.doe@gmail.com",  
  customFields: { "Age": "29"},  
  tags: ["API Team"],  
}

则最终联系人将具有 John 作为 firstName,生日为 1989-03-03,同时具有标签 DeveloperAPI Team,以及自定义字段 DesignationAge

属性

  • firstName: 字符串类型
  • lastName: 字符串类型
  • email: 字符串类型
  • company: 字符串类型
  • birthday: 格式为 YYYY-MM-DD 的字符串,例如:2016-11-21
  • customFields: 类型 map[string]string
  • tags: 字符串数组

响应

{
  "status": "200",
  "message": "OK",
  "data": {
    "encryptedTeamId": "CLdh9Ig5GLIN1u8gTRvoja",
    "encryptedId": "c9QF63nrBenCaAXe660byz",
    "tags": [
      "API Team",
      "Tech"
    ],
    "firstName": "John",
    "lastName": "Doe",
    "email": "john.doe@gmail.com",
    "company": "",
    "birthday": "1989-03-03",
    "customFields": {
      "Age": "29",
      "Designation": "Software Engineer"
    }
  }
}

跟踪 API 方法

跟踪 API 方法用于将 tags 与联系人关联。您可以根据标签添加自动化规则,并将执行这些规则。例如

  • 在用户注册时,为用户启动上船 drip。
  • 账户升级时,将用户添加到付费用户列表并启动账户扩展 drip。

响应

{

"status": "200",
"message": "OK",
"data": "success"

}

此 PHP 包由 Swagger Codegen 项目自动生成

  • API 版本:v1
  • 构建包:class io.swagger.codegen.languages.PhpClientCodegen

要求

PHP 5.4.0 及更高版本

安装和用法

Composer

要使用 Composer 安装绑定,请将以下内容添加到 composer.json

{
  "repositories": [
    {
      "type": "git",
      "url": "https://github.com/sendx/sendx-api-php.git"
    }
  ],
  "require": {
    "/": "*@dev"
  }
}

然后运行 composer install

手动安装

下载文件并包含 autoload.php

    require_once('/path/to/SwaggerClient-php/autoload.php');

测试

要运行单元测试

composer install
./vendor/bin/phpunit

入门

请按照 安装程序 进行操作,然后运行以下命令

<?php
require_once(__DIR__ . '/vendor/autoload.php');

$api_instance = new Swagger\Client\Api\ContactApi();
$api_key = "api_key_example"; // string | 
$team_id = "team_id_example"; // string | 
$body = new \Swagger\Client\Model\Contact(); // \Swagger\Client\Model\Contact | Contact details

try {
    $result = $api_instance->contactIdentifyPost($api_key, $team_id, $body);
    print_r($result);
} catch (Exception $e) {
    echo 'Exception when calling ContactApi->contactIdentifyPost: ', $e->getMessage(), PHP_EOL;
}

?>

API 端点文档

所有 URI 都相对于 http://app.sendx.io/api/v1

方法HTTP 请求描述
ContactApicontactIdentifyPostPOST /contact/identify将联系人识别为用户
ContactApicontactTrackPostPOST /contact/track使用标签添加跟踪信息到联系人

模型文档

授权文档

所有端点均不需要授权。

作者