我有一个东西板。如果我在CLI中执行此命令,则板上的一个LED可以通过POST请求(http集成)打开:
from datetime import datetime
df = df.loc[df.index.date == datetime(2017, 12, 1).date()]
print (df)
2017-12-01 00:00:00 2641.50
2017-12-01 00:05:00 2641.75
2017-12-01 00:10:00 2641.75
2017-12-01 00:15:00 2641.50
2017-12-01 00:20:00 2641.50
Name: o, dtype: float64
但是现在我想用PHP做到这一点,所以我有以下代码:
curl -i -X POST --data '{"dev_id":"myid","port": 1,"confirmed": false, "payload_raw": "MDA="}' https://integrations.thethingsnetwork.org/ttn-eu/api/v2/down/myapplication/test?key=ttn-account-v2.thekey
它仅返回HTTP400 badrequest。我在做什么错了?
答案 0 :(得分:2)
尝试使用json_encode
对数据进行编码:
$data_to_post = json_encode([
'dev_id' => 'mydevice',
'port' => 1,
'confirmed' => false,
'payload_raw' => 'MDA=']);