Endpoint работает, но токен устарел:
POST /core/latest/api/devices/343438357237630F/downlinkMessages HTTP/1.1
Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzY29wZSI6WyJTVUJTQ1JJQkVSOjEwMDAwMDA3NSJdLCJleHAiOjM2NzIxNDY2NTEsImp0aSI6ImY4MDFkODcyLWNlYjMtNDY0MS1iNmZiLWU2N2NlZmM0MGMzYiIsImNsaWVudF9pZCI6ImVydGVsZWNvbS1hcGkvdmFydmFyYS5ydWRlbmtvMUBkb21ydS5ydSJ9.kdQqIHpVdTE-1N5K9cTC872TkzhCKMIH0uU2FGWHW3n3nSGiDlP5pG5rs4jb_4xRmvZ4hJ20IsgXNj5-hcmuw
Content-type: application/json
Accept: application/json
Content-Length: 44
Host: dx-api-ru1.thingpark.com
Connection: Keep-Alive
User-Agent: Apache-HttpClient/4.1.1 (java 1.5)
{"payloadHex": "030100", "targetPorts": "2"}
Ответ от сервера:
HTTP/1.1 400 Bad Request
Server=nginx
Date=Mon, 05 Aug 2019 14:25:40 GMT
Content-Length=103
Connection=keep-alive
{
"code" : 400,
"message" : "Bad request: Invalid token or token has expired",
"errorId" : null
}
Вот сам CURL:
curl -s -X POST -H "Content-type: application/json" -H 'Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzY29wZSI6WyJTVUJTQ1JJQkVSOjEwMDAwMDA3NSJdLCJleHAiOjM2NzIxNDY2NTEsImp0aSI6ImY4MDFkODcyLWNlYjMtNDY0MS1iNmZiLWU2N2NlZmM0MGMzYiIsImNsaWVudF9pZCI6ImVydGVsZWNvbS1hcGkvdmFydmFyYS5ydWRlbmtvMUBkb21ydS5ydSJ9.kdQqIHpVdTE-1N5K9cTC872TkzhCKMIH0uU2FGWHW3n3nSGiDlP5pG5rs4jb_4xRmvZ4hJ20IsgXNj5-hcmuw' -d '{"payloadHex": "030100", "targetPorts": "2"}' https://dx-api-ru1.thingpark.com/core/latest/api/devices/343438357237630F/downlinkMessages
Ну и разжеванный код на PHP:
<?php
$url = 'https://dx-api-ru1.thingpark.com/core/latest/api/devices/343438357237630F/downlinkMessages';
$ch = curl_init($url);
$data = array(
'payloadHex' => '030100',
'targetPorts' => '2'
);
$payload = json_encode($data);
curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type:application/json', 'Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzY29wZSI6WyJTVUJTQ1JJQkVSOjEwMDAwMDA3NSJdLCJleHAiOjM2NzIxNDY2NTEsImp0aSI6ImY4MDFkODcyLWNlYjMtNDY0MS1iNmZiLWU2N2NlZmM0MGMzYiIsImNsaWVudF9pZCI6ImVydGVsZWNvbS1hcGkvdmFydmFyYS5ydWRlbmtvMUBkb21ydS5ydSJ9.kdQqIHpVdTE-1N5K9cTC872TkzhCKMIH0uU2FGWHW3n3nSGiDlP5pG5rs4jb_4xRmvZ4hJ20IsgXNj5-hcmuw'));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
echo $result = curl_exec($ch);
curl_close($ch);
?>