Для работы с API в PHP существует готовый клиент, скачать который вы можете по ссылке
Для авторизации по API в заголовках запроса передается ключ API и секретный ключ, которые можно получить в личном кабинете -> раздел настройки -> API.
curl -X POST \
-H "Content-Type: application/json" \
-H "Authorization: Token 039c1953b52fe5345d6b1ea174e7d233" \
-H "X-Secret: 23e67627f24a52a2ab1aa82da7ea5446" \
https://love-crm.ru/api/v1/check/status
var url = "https://love-crm.ru/api/v1/check/status";
var token = "039c1953b52fe5345d6b1ea174e7d233";
var secret = "23e67627f24a52a2ab1aa82da7ea5446";
var query = {};
var options = {
method: "POST",
mode: "cors",
headers: {
"Content-Type": "application/json",
"Authorization": "Token " + token,
"X-Secret": secret
},
body: JSON.stringify(query)
} fetch(url, options)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log("error", error));
// Check Status API
$token = "a25bea39750a33cf765c46b920841911";
$secret = "2dfb56554df7bf396e58acc7b07fcf22";
$lovecrm = new \LoveCrm\LoveCrmClient($token, $secret);
/**
* @return json $response
*/
$response = $lovecrm->checkStatus();
print_r($response); // {"code":200,"message":"Connect success"}
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://love-crm.ru/api/v1/check/status');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$headers = array();
$headers[] = 'Content-Type: application/json';
$headers[] = 'Authorization: Token 039c1953b52fe5345d6b1ea174e7d233';
$headers[] = 'X-Secret: 23e67627f24a52a2ab1aa82da7ea5446';
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($ch);
if (curl_errno($ch)) { echo 'Error:' . curl_error($ch);
}
curl_close($ch);
curl -X POST \
-H "Content-Type: application/json" \
-H "Authorization: Token 039c1953b52fe5345d6b1ea174e7d233" \
-H "X-Secret: 23e67627f24a52a2ab1aa82da7ea5446" \
https://love-crm.ru/api/v1/deals/getstatuses
var url = "https://love-crm.ru/api/v1/deals/getstatuses";
var token = "039c1953b52fe5345d6b1ea174e7d233";
var secret = "23e67627f24a52a2ab1aa82da7ea5446";
var query = {};
var options = {
method: "POST",
mode: "cors",
headers: {
"Content-Type": "application/json",
"Authorization": "Token " + token,
"X-Secret": secret
},
body: JSON.stringify(query)
} fetch(url, options)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log("error", error));
// Get Deal Statuses
$token = "a25bea39750a33cf765c46b920841911";
$secret = "2dfb56554df7bf396e58acc7b07fcf22";
$lovecrm = new \LoveCrm\LoveCrmClient($token, $secret);
/**
* @return json $response
*/
$response = $lovecrm->dealsStatuses();
print_r($response);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://love-crm.ru/api/v1/deals/getstatuses');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$headers = array();
$headers[] = 'Content-Type: application/json';
$headers[] = 'Authorization: Token 039c1953b52fe5345d6b1ea174e7d233';
$headers[] = 'X-Secret: 23e67627f24a52a2ab1aa82da7ea5446';
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($ch);
if (curl_errno($ch)) { echo 'Error:' . curl_error($ch);
}
curl_close($ch);
curl -X POST \
-H "Content-Type: application/json" \
-H "Authorization: Token 039c1953b52fe5345d6b1ea174e7d233" \
-H "X-Secret: 23e67627f24a52a2ab1aa82da7ea5446" \
https://love-crm.ru/api/v1/deals/getorigins
var url = "https://love-crm.ru/api/v1/deals/getorigins";
var token = "039c1953b52fe5345d6b1ea174e7d233";
var secret = "23e67627f24a52a2ab1aa82da7ea5446";
var query = {};
var options = {
method: "POST",
mode: "cors",
headers: {
"Content-Type": "application/json",
"Authorization": "Token " + token,
"X-Secret": secret
},
body: JSON.stringify(query)
} fetch(url, options)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log("error", error));
// Get Deal Origins
$token = "a25bea39750a33cf765c46b920841911";
$secret = "2dfb56554df7bf396e58acc7b07fcf22";
$lovecrm = new \LoveCrm\LoveCrmClient($token, $secret);
/**
* @return json $response
*/
$response = $lovecrm->dealsOrigins();
print_r($response);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://love-crm.ru/api/v1/deals/getorigins');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$headers = array();
$headers[] = 'Content-Type: application/json';
$headers[] = 'Authorization: Token 039c1953b52fe5345d6b1ea174e7d233';
$headers[] = 'X-Secret: 23e67627f24a52a2ab1aa82da7ea5446';
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($ch);
if (curl_errno($ch)) { echo 'Error:' . curl_error($ch);
}
curl_close($ch);
curl -X POST \
-H "Content-Type: application/json" \
-H "Authorization: Token 039c1953b52fe5345d6b1ea174e7d233" \
-H "X-Secret: 23e67627f24a52a2ab1aa82da7ea5446" \
https://love-crm.ru/api/v1/deals/getcategories
var url = "https://love-crm.ru/api/v1/deals/getcategories";
var token = "039c1953b52fe5345d6b1ea174e7d233";
var secret = "23e67627f24a52a2ab1aa82da7ea5446";
var query = {};
var options = {
method: "POST",
mode: "cors",
headers: {
"Content-Type": "application/json",
"Authorization": "Token " + token,
"X-Secret": secret
},
body: JSON.stringify(query)
} fetch(url, options)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log("error", error));
// Get Deal Categories
$token = "a25bea39750a33cf765c46b920841911";
$secret = "2dfb56554df7bf396e58acc7b07fcf22";
$lovecrm = new \LoveCrm\LoveCrmClient($token, $secret);
/**
* @return json $response
*/
$response = $lovecrm->dealsCategories();
print_r($response);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://love-crm.ru/api/v1/deals/getcategories');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$headers = array();
$headers[] = 'Content-Type: application/json';
$headers[] = 'Authorization: Token 039c1953b52fe5345d6b1ea174e7d233';
$headers[] = 'X-Secret: 23e67627f24a52a2ab1aa82da7ea5446';
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($ch);
if (curl_errno($ch)) { echo 'Error:' . curl_error($ch);
}
curl_close($ch);
curl -X POST \
-H "Content-Type: application/json" \
-H "Authorization: Token 039c1953b52fe5345d6b1ea174e7d233" \
-H "X-Secret: 23e67627f24a52a2ab1aa82da7ea5446" \
-d '{"name":"Deal Name","price":0,"id_cat":0,"id_status":0,"id_origin":0,"id_client":0,"archive":false,"tags":"","color":"","text":""}' \
https://love-crm.ru/api/v1/deals/add
var url = "https://love-crm.ru/api/v1/deals/add";
var token = "039c1953b52fe5345d6b1ea174e7d233";
var secret = "23e67627f24a52a2ab1aa82da7ea5446";
var query = {
"name":"Deal Name",
"price":0,
"id_cat":0,
"id_status":0,
"id_origin":0,
"id_client":0,
"archive":false,
"tags":"",
"color":"",
"text":""
};
var options = {
method: "POST",
mode: "cors",
headers: {
"Content-Type": "application/json",
"Authorization": "Token " + token,
"X-Secret": secret
},
body: JSON.stringify(query)
} fetch(url, options)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log("error", error));
// Add Deal
$token = "a25bea39750a33cf765c46b920841911";
$secret = "2dfb56554df7bf396e58acc7b07fcf22";
$lovecrm = new \LoveCrm\LoveCrmClient($token, $secret);
/**
* @return json $response
*/
$response = $lovecrm->addDeal([
'name' => 'Тестовая сделка', // Name deal (required field)
'price' => 0.0, // Price deal (optional)
'id_cat' => 0, // Category ID (optional)
'id_status' => 0, // Status deal ID (optional)
'id_origin' => 0, // Origin ID (optional)
'id_client' => 0, // Client ID (optional)
'archive' => false, // Moving a Deal to the archive (optional)
'tags' => '', // Tags separated by commas (optional)
'color' => '', // Color Deal in HEX, example: AD3939 (optional)
'text' => '', // Text detail description Deal (optional)
]);
print_r($response); // {"code":200,"message":"Deal added successfully","id_deal":"24"}
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://love-crm.ru/api/v1/deals/add');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "{\"name\":\"Deal Name\",\"price\":0,\"id_cat\":0,\"id_status\":0,\"id_origin\":0,\"id_client\":0,\"archive\":false,\"tags\":\"\",\"color\":\"\",\"text\":\"\"}");
$headers = array();
$headers[] = 'Content-Type: application/json';
$headers[] = 'Authorization: Token 039c1953b52fe5345d6b1ea174e7d233';
$headers[] = 'X-Secret: 23e67627f24a52a2ab1aa82da7ea5446';
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($ch);
if (curl_errno($ch)) { echo 'Error:' . curl_error($ch);
}
curl_close($ch);
curl -X POST \
-H "Content-Type: application/json" \
-H "Authorization: Token 039c1953b52fe5345d6b1ea174e7d233" \
-H "X-Secret: 23e67627f24a52a2ab1aa82da7ea5446" \
-d '{"name":"Task Name","date_from":"","date_to":"","all_day":false,"color":"","text":"","id_deal":0,"id_status":0,"id_type":0}' \
https://love-crm.ru/api/v1/tasks/add
var url = "https://love-crm.ru/api/v1/tasks/add";
var token = "039c1953b52fe5345d6b1ea174e7d233";
var secret = "23e67627f24a52a2ab1aa82da7ea5446";
var query = {
"name":"Task Name",
"date_from":"",
"date_to":"",
"all_day":false,
"color":"",
"text":"",
"id_deal":0,
"id_status":0,
"id_type":0
};
var options = {
method: "POST",
mode: "cors",
headers: {
"Content-Type": "application/json",
"Authorization": "Token " + token,
"X-Secret": secret
},
body: JSON.stringify(query)
} fetch(url, options)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log("error", error));
// Add Task
$token = "a25bea39750a33cf765c46b920841911";
$secret = "2dfb56554df7bf396e58acc7b07fcf22";
$lovecrm = new \LoveCrm\LoveCrmClient($token, $secret);
/**
* @return json $response
*/
$response = $lovecrm->addTask([
'name' => 'Тестовая задача', // Name Task (required field)
'date_from' => '', // Task start Date-time, example: 2022-05-28T15:00:00 (required field)
'date_to' => '', // Task end Date-time, example: 2022-05-28T17:00:00 (required field)
'all_day' => false, // All day duration (optional)
'color' => '', // Color Task in HEX, example: AD3939 (optional)
'text' => '', // Text detail description Task (optional)
'id_deal' => 0, // Deal ID (optional)
'id_status' => 0, // Status task ID (optional)
'id_type' => 0, // Task type ID (optional)
]);
print_r($response); // {"code":200,"message":"Task added successfully","id_task":"75"}
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://love-crm.ru/api/v1/tasks/add');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "{\"name\":\"Task Name\",\"date_from\":\"\",\"date_to\":\"\",\"all_day\":false,\"color\":\"\",\"text\":\"\",\"id_deal\":0,\"id_status\":0,\"id_type\":0}");
$headers = array();
$headers[] = 'Content-Type: application/json';
$headers[] = 'Authorization: Token 039c1953b52fe5345d6b1ea174e7d233';
$headers[] = 'X-Secret: 23e67627f24a52a2ab1aa82da7ea5446';
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($ch);
if (curl_errno($ch)) { echo 'Error:' . curl_error($ch);
}
curl_close($ch);
curl -X POST \
-H "Content-Type: application/json" \
-H "Authorization: Token 039c1953b52fe5345d6b1ea174e7d233" \
-H "X-Secret: 23e67627f24a52a2ab1aa82da7ea5446" \
https://love-crm.ru/api/v1/clients/getstatuses
var url = "https://love-crm.ru/api/v1/clients/getstatuses";
var token = "039c1953b52fe5345d6b1ea174e7d233";
var secret = "23e67627f24a52a2ab1aa82da7ea5446";
var query = {};
var options = {
method: "POST",
mode: "cors",
headers: {
"Content-Type": "application/json",
"Authorization": "Token " + token,
"X-Secret": secret
},
body: JSON.stringify(query)
} fetch(url, options)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log("error", error));
// Get Deal Statuses
$token = "a25bea39750a33cf765c46b920841911";
$secret = "2dfb56554df7bf396e58acc7b07fcf22";
$lovecrm = new \LoveCrm\LoveCrmClient($token, $secret);
/**
* @return json $response
*/
$response = $lovecrm->clientsStatuses();
print_r($response);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://love-crm.ru/api/v1/clients/getstatuses');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$headers = array();
$headers[] = 'Content-Type: application/json';
$headers[] = 'Authorization: Token 039c1953b52fe5345d6b1ea174e7d233';
$headers[] = 'X-Secret: 23e67627f24a52a2ab1aa82da7ea5446';
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($ch);
if (curl_errno($ch)) { echo 'Error:' . curl_error($ch);
}
curl_close($ch);
curl -X POST \
-H "Content-Type: application/json" \
-H "Authorization: Token 039c1953b52fe5345d6b1ea174e7d233" \
-H "X-Secret: 23e67627f24a52a2ab1aa82da7ea5446" \
-d '{"realname":"User Name","realnamefind":false,"email":"","emailfind":true,"phone":"","phonefind":true,"position":"","id_status":0,"text":"","fields":{"nameField":"valueField"}}' \
https://love-crm.ru/api/v1/clients/add
var url = "https://love-crm.ru/api/v1/clients/add";
var token = "039c1953b52fe5345d6b1ea174e7d233";
var secret = "23e67627f24a52a2ab1aa82da7ea5446";
var query = {
"realname":"User Name",
"realnamefind":false,
"email":"",
"emailfind":true,
"phone":"",
"phonefind":true,
"position":"",
"id_status":0,
"text":"",
"fields":{"nameField":"valueField"}
};
var options = {
method: "POST",
mode: "cors",
headers: {
"Content-Type": "application/json",
"Authorization": "Token " + token,
"X-Secret": secret
},
body: JSON.stringify(query)
}
fetch(url, options)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log("error", error));
// Add Task
$token = "a25bea39750a33cf765c46b920841911";
$secret = "2dfb56554df7bf396e58acc7b07fcf22";
$lovecrm = new \LoveCrm\LoveCrmClient($token, $secret);
/**
* @return json $response
*/
$response = $lovecrm->addClient([
'realname' => '(ТЕСТ)Иванов Иван Иванович', // Real name client (required field)
'realnamefind' => false, // Find a client by Name in my Datebase (optional, default = false)
'email' => '', // E-Mail client (optional)
'emailfind' => true, // Find a client by E-Mail in my Datebase (optional, default = false)
'phone' => '', // Phone client ID (optional)
'phonefind' => true, // Find a client by Phone in my Datebase (optional, default = false)
'position' => '', // Position(job title) client ID (optional)
'id_status' => 0, // Status client ID (optional)
'text' => '', // Text detail description Client (optional)
'fields' => [ // Array addition fields (optional)
'nameField' => 'valueField',
]
]);
print_r($response); // {"code":200,"message":"Client added successfully","id_client":"101"}
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://love-crm.ru/api/v1/clients/add');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "{\"realname\":\"User Name\",\"realnamefind\":false,\"email\":\"\",\"emailfind\":true,\"phone\":\"\",\"phonefind\":true,\"position\":\"\",\"id_status\":0,\"text\":\"\",\"fields\":{\"nameField\":\"valueField\"}}");
$headers = array();
$headers[] = 'Content-Type: application/json';
$headers[] = 'Authorization: Token 039c1953b52fe5345d6b1ea174e7d233';
$headers[] = 'X-Secret: 23e67627f24a52a2ab1aa82da7ea5446';
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($ch);
if (curl_errno($ch)) { echo 'Error:' . curl_error($ch);
}
curl_close($ch);