contact360/php-api

Contact360 API连接层

1.3.1 2024-05-15 19:13 UTC

This package is auto-updated.

Last update: 2024-09-16 12:37:50 UTC


README

用于Contact360 API通信的入口类。

目录

  1. 安装/要求
  2. 功能
  3. 用法/示例

安装/要求

要求

使用Composer安装

  1. 需要composer包
    composer require contact360/php-api
    
  2. 在您的代码中包含引用
    use Contact360\API;
    require 'vendor\autoload.php';
    

手动安装

  1. 将此存储库作为ZIP下载
  2. 解压缩并将其包含在您的代码中

功能

  • 插入网页表单联系事件
  • 插入网页购物车事件

用法/示例

用法

use Contact360\API;
$client_id = 'YOUR-CLIENT-ID';
$secret = 'YOUR-API-SECRET';
$APIClient = new API($client_id, $secret);
$form_name = 'Contact Page Form';
$enquiry_content = 'Equiry from your website:<br/>First Name: John\nLast Name: Doe';
$fields = [
    'email' => 'example@example.org', 
    'phone' => '123087923', 
    'name' => 'John Doe',
    //'firstname' => 'John', //alternative for single "name" field
    //'lastname' => 'Doe', //alternative for single "name" field
];
$result = $APIClient->insertContactForm($form_name, $enquiry_content, $fields);
if($result){
    echo 'Contact form event registered.';
}
else{
    echo 'Could not communicate to API right now.';
}

示例

  • 调试
    $APIClient = new API($client_id, $secret, true);
    $result = $APIClient->insertContactForm($form_name, $enquiry_content, $fields);
    if(!$result){
      var_dump($result->getCallResults());
    }