Есть запрос, он выводит данные в формате json, потом сохраняю в переменную. Как оттуда взять "ID,NAME,SALE". Желательно в одну строку ID,NAME,SALE. Спасибо
{
"_links": {
"self": {
"href": "/api/v2/leads?status=20728261",
"method": "get"
}
},
"_embedded": {
"items": [
{
"id": 1601345,
"name": "Тест",
"responsible_user_id": 2600929,
"created_by": 2600929,
"created_at": 1531976544,
"updated_at": 1531985130,
"account_id": 20728252,
"is_deleted": false,
"main_contact": {
"id": 4573131,
"_links": {
"self": {
"href": "/api/v2/contacts?id=4573131",
"method": "get"
}
}
},
"group_id": 0,
"company": {},
"closed_at": 0,
"closest_task_at": 0,
"tags": {},
"custom_fields": {},
"contacts": {
"id": [
4573131
],
"_links": {
"self": {
"href": "/api/v2/contacts?id=4573131",
"method": "get"
}
}
},
"status_id": 20728261,
"sale": 1300,
"loss_reason_id": 0,
"pipeline": {
"id": 1251568,
"_links": {
"self": {
"href": "/api/v2/pipelines?id=1251568",
"method": "get"
}
}
},
"_links": {
"self": {
"href": "/api/v2/leads?id=1601345",
"method": "get"
}
}
},
{
"id": 1620709,
"name": "Тест2",
"responsible_user_id": 2600929,
"created_by": 2600929,
"created_at": 1531985076,
"updated_at": 1532061092,
"account_id": 20728252,
"is_deleted": false,
"main_contact": {
"id": 4614393,
"_links": {
"self": {
"href": "/api/v2/contacts?id=4614393",
"method": "get"
}
}
},
"group_id": 0,
"company": {},
"closed_at": 0,
"closest_task_at": 0,
"tags": {},
"custom_fields": {},
"contacts": {
"id": [
4614393
],
"_links": {
"self": {
"href": "/api/v2/contacts?id=4614393",
"method": "get"
}
}
},
"status_id": 20728261,
"sale": 2300,
"loss_reason_id": 0,
"pipeline": {
"id": 1251568,
"_links": {
"self": {
"href": "/api/v2/pipelines?id=1251568",
"method": "get"
}
}
},
"_links": {
"self": {
"href": "/api/v2/leads?id=1620709",
"method": "get"
}
}
}
]
}
}
$out=curl_exec($curl); #Инициируем запрос к API и сохраняем ответ в переменную
echo $out;
curl_close($curl);
Еще вопрос
{
"_links": {
"self": {
"href": "/api/v2/leads?status=18468961",
"method": "get"
}
},
"_embedded": {
"items": [
{
"id": 7612939,
"name": "Доставка на Дзержинского 76",
"responsible_user_id": 2170399,
"created_by": 2170399,
"created_at": 1527060038,
"updated_at": 1527116634,
"account_id": 18334111,
"is_deleted": false,
"main_contact": {},
"group_id": 0,
"company": {},
"closed_at": 0,
"closest_task_at": 0,
"tags": [
{
"id": 136663,
"name": "ЗАКАЗ ИЗ ПРИЛОЖЕНИЯ"
},
{
"id": 192403,
"name": "ЦЕНТР"
}
],
"custom_fields": [
{
"id": 379810,
"name": "Количество",
"values": [
{
"value": "1"
}
],
"is_system": false
},
{
"id": 379905,
"name": "Адрес доставки",
"values": [
{
"value": "Дзержинского 76"
}
],
"is_system": false
},
{
"id": 389997,
"name": "Телефон",
"values": [
{
"value": "89659979796"
}
],
"is_system": false
}
],
"status_id": 18468961,
"sale": 0,
"loss_reason_id": 0,
"contacts": {},
"pipeline": {
"id": 980719,
"_links": {
"self": {
"href": "/api/v2/pipelines?id=980719",
"method": "get"
}
}
},
"_links": {
"self": {
"href": "/api/v2/leads?id=7612939",
"method": "get"
}
}
},
{
"id": 8317497,
"name": "Доставка на Дзержинского 51",
"responsible_user_id": 2170399,
"created_by": 2170399,
"created_at": 1531722164,
"updated_at": 1531972399,
"account_id": 18334111,
"is_deleted": false,
"main_contact": {},
"group_id": 0,
"company": {},
"closed_at": 0,
"closest_task_at": 0,
"tags": [
{
"id": 136663,
"name": "ЗАКАЗ ИЗ ПРИЛОЖЕНИЯ"
},
{
"id": 192403,
"name": "ЦЕНТР"
}
],
"custom_fields": [
{
"id": 379810,
"name": "Количество",
"values": [
{
"value": "1"
}
],
"is_system": false
},
{
"id": 379905,
"name": "Адрес доставки",
"values": [
{
"value": "Дзержинского 51"
}
],
"is_system": false
},
{
"id": 389997,
"name": "Телефон",
"values": [
{
"value": "79244694163"
}
],
"is_system": false
},
{
"id": 380773,
"name": "Подъезд",
"values": [
{
"value": "2"
}
],
"is_system": false
},
{
"id": 380777,
"name": "Этаж",
"values": [
{
"value": "7"
}
],
"is_system": false
},
{
"id": 380781,
"name": "Квартира",
"values": [
{
"value": "89"
}
],
"is_system": false
}
],
"status_id": 18468961,
"sale": 0,
"loss_reason_id": 0,
"contacts": {},
"pipeline": {
"id": 980719,
"_links": {
"self": {
"href": "/api/v2/pipelines?id=980719",
"method": "get"
}
}
},
"_links": {
"self": {
"href": "/api/v2/leads?id=8317497",
"method": "get"
}
}
},
{
"id": 8253299,
"name": "Доставка на Жорницкого",
"responsible_user_id": 2170399,
"created_by": 2170399,
"created_at": 1531350142,
"updated_at": 1531972433,
"account_id": 18334111,
"is_deleted": false,
"main_contact": {},
"group_id": 0,
"company": {},
"closed_at": 0,
"closest_task_at": 0,
"tags": [
{
"id": 136663,
"name": "ЗАКАЗ ИЗ ПРИЛОЖЕНИЯ"
},
{
"id": 192403,
"name": "ЦЕНТР"
}
],
"custom_fields": [
{
"id": 379810,
"name": "Количество",
"values": [
{
"value": "1"
}
],
"is_system": false
},
{
"id": 379905,
"name": "Адрес доставки",
"values": [
{
"value": "Жорницкого"
}
],
"is_system": false
},
{
"id": 389997,
"name": "Телефон",
"values": [
{
"value": "89142760010"
}
],
"is_system": false
},
{
"id": 380773,
"name": "Подъезд",
"values": [
{
"value": "2"
}
],
"is_system": false
},
{
"id": 380777,
"name": "Этаж",
"values": [
{
"value": "7"
}
],
"is_system": false
},
{
"id": 380781,
"name": "Квартира",
"values": [
{
"value": "53"
}
],
"is_system": false
}
],
"status_id": 18468961,
"sale": 120,
"loss_reason_id": 0,
"contacts": {},
"pipeline": {
"id": 980719,
"_links": {
"self": {
"href": "/api/v2/pipelines?id=980719",
"method": "get"
}
}
},
"_links": {
"self": {
"href": "/api/v2/leads?id=8253299",
"method": "get"
}
}
},
{
"id": 8044599,
"name": "Доставка на Борисовка 3 в1",
"responsible_user_id": 2170399,
"created_by": 2170399,
"created_at": 1530177493,
"updated_at": 1531972598,
"account_id": 18334111,
"is_deleted": false,
"main_contact": {},
"group_id": 0,
"company": {},
"closed_at": 0,
"closest_task_at": 0,
"tags": [
{
"id": 136663,
"name": "ЗАКАЗ ИЗ ПРИЛОЖЕНИЯ"
},
{
"id": 192403,
"name": "ЦЕНТР"
}
],
"custom_fields": [
{
"id": 379810,
"name": "Количество",
"values": [
{
"value": "3"
}
],
"is_system": false
},
{
"id": 379905,
"name": "Адрес доставки",
"values": [
{
"value": "Борисовка 3 в1"
}
],
"is_system": false
},
{
"id": 389997,
"name": "Телефон",
"values": [
{
"value": "89142717267"
}
],
"is_system": false
},
{
"id": 380773,
"name": "Подъезд",
"values": [
{
"value": "1"
}
],
"is_system": false
},
{
"id": 380777,
"name": "Этаж",
"values": [
{
"value": "2"
}
],
"is_system": false
},
{
"id": 380781,
"name": "Квартира",
"values": [
{
"value": "5"
}
],
"is_system": false
}
],
"status_id": 18468961,
"sale": 360,
"loss_reason_id": 0,
"contacts": {},
"pipeline": {
"id": 980719,
"_links": {
"self": {
"href": "/api/v2/pipelines?id=980719",
"method": "get"
}
}
},
"_links": {
"self": {
"href": "/api/v2/leads?id=8044599",
"method": "get"
}
}
}
]
}
}