Cumulocity:通过 deviceId 和日期时间调用所有事件

Cumulocity: Call all event by deviceId and datetime

大家好,我将 cumulocity api 与 php 一起使用,一切准备就绪。 我在通过 deviceId.

获取 event/events 时遇到问题
$url = 'https://*********.iot.a1.digital/event/events?dateFrom=' . $date . 'T' . $timeNew . '.000Z&pageSize=1000&type=lwm2m_log';


$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
// curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
    'Content-Type: application/json',
    'Acept: application/vnd.com.nsn.cumulocity.operation+json',
));

curl_setopt($ch, CURLOPT_USERPWD, "$login:$password");
$result = curl_exec($ch);
curl_close($ch);

我的url是

https://********_live.iot.a1.digital/event/events?dateFrom=2020-08-28T14:02:07.000Z&pageSize=1000&type=lwm2m_log&id=1234567

但 return 数据是所有设备的所有事件。

回答

  "events": [
        {
            "creationTime": "2020-12-07T09:49:13.879+01:00",
            "source": {
                "name": "860922049984564",
                "self": "https://t14580169.iot.a1.digital/inventory/managedObjects/1973856",
                "id": "1973856"
            },
            "type": "lwm2m_log",
            "self": "https://t14580169.iot.a1.digital/event/events/13113138",
            "time": "2020-12-07T09:49:13.874+01:00",
            "text": "Registration update: RegistrationUpdate [registrationId=ivWv8hUHh2, identity=Identity /80.75.32.47:24140[unsecure], lifeTimeInSec=null, smsNumber=null, bindingMode=null, objectLinks=[</31101/0>, </5/0>, </3/0>, </6/0>]]\nUpdated registration: Registration [registrationDate=Mon Nov 23 09:19:00 CET 2020, identity=Identity /80.75.32.47:24140[unsecure], lifeTimeInSec=360, smsNumber=null, lwM2mVersion=1.0, bindingMode=U, endpoint=860922049984564, registrationId=ivWv8hUHh2, objectLinks=[</31101/0>, </5/0>, </3/0>, </6/0>], lastUpdate=Mon Dec 07 09:49:13 CET 2020]",
            "id": "13113138"
        }
]

如何创建url通过deviceId

获取

要通过源设备ID查询事件(或其他数据类型),请改用查询参数“source”。参见 https://cumulocity.com/guides/reference/events/#events-api

您的查询应如下所示:

https://********_live.iot.a1.digital/event/events?dateFrom=2020-08-28T14:02:07.000Z&pageSize=1000&type=lwm2m_log&source=1234567