oca/x2restclient

此软件包最新版本(dev-master)没有提供许可证信息。

x2engine crm 的 REST 客户端。

dev-master 2018-10-31 19:07 UTC

README

请将以下行添加到您的 composer 文件中

    {
      "minimum-stability": "dev",
      "prefer-stable": true,
      "require": {
        "guzzlehttp/guzzle": "~6.0",
        "oca/x2restclient": "dev-master"
      }
    }

确保您运行 composer install。注意更新,因为它将更新其他所有 composer 项目。

以下是如何创建联系人的基本示例

<?php
// require the composer autoload file
require __DIR__ . '/vendor/autoload.php';

// set the rest client
use Oca\X2RestClient\Client as X2RestClient;

// set your env variables to craete the clietn object.
$client = new X2RestClient(getenv('X2_URL'), getenv('X2_USER'), getenv('X2_KEY'));

// set the new contacts info
$data = array('firstName' => 'test', 'lastName' => 'contact', 'email' => 'whatever@gmail.com');

// create a contact and dump the result
$contact = $client->createContact($data);
var_dump($contact);  // this will contain the new contacts info you just created.

?>

$mapper 对于 createContact() 和 updateContact() 的样子是 mywebfield => x2fieldname(键是 MY 字段名,值是 x2 的字段名,如下所示

    $mapper = [
        'First_Name' => 'firstName',
        'Last_Name' => 'lastName',
        'Primary_Email' => 'email',
    ];