Copy
curl -X POST -H "X-API-Key: YOUR_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "Иван Петров",
"phone": "+7 (999) 123-45-67",
"address": "ул. Пушкина, д. 10, кв. 5",
"email": "ivan@example.com",
"delivery_time": "завтра к 14:00",
"items": [
{"sku": "FL-001", "type": "flower", "qty": 5},
{"sku": "BQ-005", "type": "bouquet", "qty": 1}
]
}' \
https://vbutone.ru/api/order
$ch = curl_init('https://vbutone.ru/api/order');
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_HTTPHEADER => [
'X-API-Key: YOUR_KEY',
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => json_encode([
'name' => 'Иван Петров',
'phone' => '+7 (999) 123-45-67',
'address' => 'ул. Пушкина, д. 10, кв. 5',
'email' => 'ivan@example.com',
'delivery_time' => 'завтра к 14:00',
'items' => [
['sku' => 'FL-001', 'type' => 'flower', 'qty' => 5],
['sku' => 'BQ-005', 'type' => 'bouquet', 'qty' => 1],
],
]),
CURLOPT_RETURNTRANSFER => true,
]);
$data = json_decode(curl_exec($ch), true);
if ($data['success']) {
echo "Заказ #{$data['order_id']} — {$data['total']} ₽\n";
} else {
echo "Ошибка: " . ($data['error'] ?? implode(', ', $data['errors'] ?? [])) . "\n";
}
r = requests.post(f"{BASE}/order", headers=headers, json={
"name": "Иван Петров",
"phone": "+7 (999) 123-45-67",
"address": "ул. Пушкина, д. 10, кв. 5",
"email": "ivan@example.com",
"delivery_time": "завтра к 14:00",
"items": [
{"sku": "FL-001", "type": "flower", "qty": 5},
{"sku": "BQ-005", "type": "bouquet", "qty": 1},
]
})
data = r.json()
if data["success"]:
print(f"Заказ #{data['order_id']} — {data['total']} ₽")
else:
print(f"Ошибка: {data.get('error', data.get('errors'))}")