# JSON
curl -X POST "http://43.142.37.44/api.php?action=ingest" \
-H "Content-Type: application/json" \
-d '{"event_type":"学生非法闯入","location":"停车场","details":"默认上报","alert_level":"high"}'
# 表单
curl -X POST "http://43.142.37.44/api.php?action=ingest" \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "event_type=学生非法闯入&location=停车场&details=默认上报&alert_level=high"
// JSON
fetch('http://43.142.37.44/api.php?action=ingest', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ event_type: '学生非法闯入', location: '停车场', details: '默认上报', alert_level: 'high' })
}).then(r => r.json()).then(console.log);
// 表单
const p = new URLSearchParams();
p.append('event_type','学生非法闯入');
p.append('location','停车场');
p.append('details','默认上报');
p.append('alert_level','high');
fetch('http://43.142.37.44/api.php?action=ingest', {
method: 'POST',
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
body: p.toString()
}).then(r => r.json()).then(console.log);
import requests
import json
data = {
'event_type': 'parking_access',
'location': '地下停车场入口',
'person_type': 'student',
'details': '学生进入危险区域:停车场'
}
response = requests.post(
'http://43.142.37.44/api.php?action=ingest',
headers={'Content-Type': 'application/json'},
data=json.dumps(data)
)
result = response.json()
print(result)
import urequests
import ujson
data = ujson.dumps({
'event_type': 'parking_access',
'location': '地下停车场入口',
'person_type': 'student',
'details': '学生进入危险区域:停车场'
})
response = urequests.post(
'http://43.142.37.44/api.php?action=ingest',
headers={'Content-Type': 'application/json'},
data=data
)
print(response.text)