 
  
 {
"store": {
    "book": [
      { "category": "reference",
        "author": "Nigel Rees",
        "title": "Sayings of the Century",
        "price": 8.95,
        "available": true
      },
      { "category": "fiction",
        "author": "Evelyn Waugh",
        "title": "Sword of Honour",
        "price": 12.99,
        "available": false
      },
      { "category": "fiction",
        "author": "Herman Melville",
        "title": "Moby Dick",
        "isbn": "0-553-21311-3",
        "price": 8.99,
        "available": true
      },
      { "category": "fiction",
        "author": "J. R. R. Tolkien",
        "title": "The Lord of the Rings",
        "isbn": "0-395-19395-8",
        "price": 22.99,
        "available": false
      }
    ],
    "bicycle": {
      "color": "red",
      "price": 19.95,
      "available": true
    }
  },
  "authors": [
    "Nigel Rees",
    "Evelyn Waugh",
    "Herman Melville",
    "J. R. R. Tolkien"
  ]
}
 
 {
    "sensei":
        [
            {
                "id":"118261",
                "name":"Бытовая техника онлайн",
                "date_create":"1545042870",
                "created_user_id":"2368945", 
                "last_modified":"1545135210",
                "price":"1000000",
                "responsible_user_id":"1320969",
                "linked_company_id":"456127",
                "pipeline_id":"1509766",
                "date_close":"0",
                "closest_task":"1545135209",
                "status_id":"23300671"
            }
 
 <?php
// получаем информацию о сделке
$lead = $_POST['sensei'][0];
// делаем необходимую обработку ...
// и получаем результат работы
$result = 'result1';
// в заголовке запроса также получаем hash-значение, запущенного процесса
$hash = $_SERVER['HTTP_X_HASH'];
// продолжаем работу Сенсея с результатом result1
$link = 'https://api.sensei.plus/webhook?hash='.$hash.'&result='.$result;
$curl = curl_init();
curl_setopt($curl,CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl,CURLOPT_USERAGENT, 'sensei-API-client/1.4');
curl_setopt($curl,CURLOPT_URL, $link);
curl_setopt($curl,CURLOPT_HEADER, false);
$out = curl_exec($curl);
curl_close($curl);
 
 {
  "status": "success",
  "data": {
    "user": {
      "id": 123,
      "name": "John Doe",
      "email": "johndoe@example.com",
      "phone": "+1234567890",
      "address": "123 Main St, Anytown, USA",
      "timezone": "UTC+3"
    },
    "orders": [
      {
        "id": 1,
        "product": "Product 1",
        "quantity": 2,
        "price": 10.99,
        "status": "completed"
      },
      {
        "id": 2,
        "product": "Product 2",
        "quantity": 1,
        "price": 19.99,
        "status": "pending"
      }
    ]
  }
}
$localParams = [
    'name1' => ‘valeu1’,
    'name2' => ‘value2’
];
senseiSend($result, $localParams);
function senseiSend($result, $localParams = [])
{
    $hash = $_SERVER['HTTP_X_HASH'];
    $body = [
        'params' => [
            'local' => $localParams
        ]
    ];
    $body = json_encode($body);
    $link = 'https://api.sensei.plus/webhook?hash=' . $hash . '&result=' . $result;
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($curl, CURLOPT_USERAGENT, 'sensei-API-client/1.4');
    curl_setopt($curl, CURLOPT_URL, $link);
    curl_setopt($curl, CURLOPT_HEADER, false);
    curl_setopt($curl, CURLOPT_POST, 1);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $body);
    curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-Type:application/json'));
    $out = curl_exec($curl);
    curl_close($curl);
}
 
 