Azure IOT Hub Rest API with Javascript
Azure IOT Hub Rest API with Javascript
我想从端点接收物联网集线器消息。使用客户端Javascript和REST。
我使用本文 https://msdn.microsoft.com/nl-nl/library/mt590786.aspx 创建 URL。
这是我的代码:
function readIOTHub()
{
$.getJson("https://MyIOTHub.azure-devices.net/devices/device1/messages/devicebound?api-version=2016-02-03", function(result)
{
alert(result);
});
}
但我的请求没有收到任何消息。有人知道如何使用 Javascript REST 从 IOT Hub 接收消息吗?
我认为这目前是不可能的,首先是因为,从我所看到的,Azure IoT 中心 REST API 不会发出 CORS 请求(即它们不会写入 CORS 标头访问控制允许源),因此您的 JS 客户端无法从浏览器中访问它。
你可能想要查看 IoT 中心的 Node.js sdk,但话又说回来,这是在 Node.js 的上下文中。
如果你对node.js没问题,它就会变得简单得多。
希望这有帮助!
莫特
相关文章:
- Angular 2.0 with JavaScript or TypeScript?
- errors with Javascript try catch
- Laravel 4 render() PDF with Javascript
- Trouble overlaying one div with another with JavaScript &
- Replace a "href" element with javascript
- geolocation with javascript and ruby on rails
- Rails 4 jQuery conflicts with javascript
- PHP Error with Javascript
- listen to 'CTRL+N' with javascript
- Dissect an id with javascript?
- change jquery masonry css with javascript
- JQuery Mobile Styling With JavaScript
- Missing ) with JavaScript Code
- RadioButton with Javascript (MVC3)
- Perl with Javascript (Perlscript)
- Image Rollovers with Javascript
- javascript innerhtml with javascript variables
- AngularJS conflicts with JavaScript minifier
- sqlite with javascript with phonegap using build.phonegap.co
- onClientClick with JavaScript function and eval