我是IDAS和Fiware的新手。我正在使用Figway(https://github.com/telefonicaid/fiware-figway),当我尝试使用此命令发送观察时我遇到了问题:
<?php
ini_set('display_errors', 1);
$string = <<<HTML
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body>
<GetCurrentExchangeRatesResponse xmlns="http://www.mnb.hu/webservices/" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<GetCurrentExchangeRatesResult>
<MNBCurrentExchangeRates>
<Day date="2017-05-25">
<Rate unit="1" curr="AUD">204,7</Rate>
<Rate unit="1" curr="BGN">157,51</Rate>
<Rate unit="1" curr="BRL">83,66</Rate>
<Rate unit="1" curr="CAD">204,06</Rate>
<Rate unit="1" curr="CHF">282,21</Rate>
<Rate unit="1" curr="CNY">39,89</Rate>
<Rate unit="1" curr="CZK">11,65</Rate>
<Rate unit="1" curr="DKK">41,4</Rate>
<Rate unit="1" curr="EUR">308,06</Rate>
<Rate unit="1" curr="GBP">355,61</Rate>
<Rate unit="1" curr="HKD">35,17</Rate>
<Rate unit="1" curr="HRK">41,48</Rate>
<Rate unit="100" curr="IDR">2,06</Rate>
<Rate unit="1" curr="ILS">76,56</Rate>
<Rate unit="1" curr="INR">4,24</Rate>
<Rate unit="1" curr="ISK">2,73</Rate>
<Rate unit="100" curr="JPY">245,13</Rate>
<Rate unit="100" curr="KRW">24,49</Rate>
<Rate unit="1" curr="MXN">14,89</Rate>
<Rate unit="1" curr="MYR">64,07</Rate>
<Rate unit="1" curr="NOK">32,92</Rate>
<Rate unit="1" curr="NZD">192,59</Rate>
<Rate unit="1" curr="PHP">5,5</Rate>
<Rate unit="1" curr="PLN">73,67</Rate>
<Rate unit="1" curr="RON">67,7</Rate>
<Rate unit="1" curr="RSD">2,51</Rate>
<Rate unit="1" curr="RUB">4,88</Rate>
<Rate unit="1" curr="SEK">31,68</Rate>
<Rate unit="1" curr="SGD">197,91</Rate>
<Rate unit="1" curr="THB">8,01</Rate>
<Rate unit="1" curr="TRY">76,91</Rate>
<Rate unit="1" curr="UAH">10,43</Rate>
<Rate unit="1" curr="USD">274,03</Rate>
<Rate unit="1" curr="ZAR">21,23</Rate>
</Day>
</MNBCurrentExchangeRates>
</GetCurrentExchangeRatesResult>
</GetCurrentExchangeRatesResponse>
</s:Body>
</s:Envelope>
HTML;
$xml= html_entity_decode($string);
$domDocument = new DOMDocument();
$domDocument->loadXML($xml);
$results=$domDocument->getElementsByTagName("Day");
foreach($results->item(0)->childNodes as $node)
{
if($node instanceof DOMElement)
{
echo $node->nodeValue;
}
}
这是回复:
python SendObservation.py sensor001x 't|23'
你可以帮帮我吗?哪里错了?我使用RaspberryPi。
非常感谢。
答案 0 :(得分:0)
不确定这是否可能与问题的原因有关,但使用Content-Type: application/json
而实际有效负载不是JSON(它是t|23
,我理解对应于text / plain)似乎是错的。