简体   繁体   English

IdHTTP以确保将数据推送到Ubidots(FMX,WIN32)

[英]IdHTTP to ensure push data to Ubidots (FMX, WIN32)

I can push an encrypted piece of humidity data up to my Ubidots cloud database by simply loading the following url in a web browser: 只需将以下URL加载到Web浏览器中,我就可以将一块湿度数据加密到我的Ubidots云数据库中:

https://industrial.ubidots.com/api/v1.6/devices/MYDEVICENAME/?token=MYTOKENHERE&_method=post&humidity=15.9 https://industrial.ubidots.com/api/v1.6/devices/MYDEVICENAME/?token=MYTOKENHERE&_method=post&humidity=15.9

When I do that, I get the success response in the browser window 当我这样做时,我会在浏览器窗口中获得成功响应

{"humidity": [{"status_code": 201}]}

and the data shows up in my data table on Ubidots. 数据显示在我的Ubidots数据表中。

Now, I want to do this from an FMX app (C++ on Win32) without a visible browser, and I would like to check that I get the nice "201" response code. 现在,我想在没有可见浏览器的情况下从FMX应用程序(Win32上的C ++)执行此操作,并且我想检查是否获得了不错的“ 201”响应代码。 I looked at this link and cobbled up the following line of code: 我查看了此链接,并整理了以下代码行:

Memo1->Text = IdHTTP1->Get("https://industrial.ubidots.com/api/v1.6/devices/MYDEVICENAME/?token=MYTOKENHERE&_method=post&humidity=6.9");

When I run it, I get a "Could not load SSL library" error message. 运行它时,出现“无法加载SSL库”错误消息。 How do I tell TIdHTTP to use SSL so it can handle the HTTPS? 如何告诉TIdHTTP使用SSL,以便它可以处理HTTPS? Is there a better, cleaner way to do this? 有没有更好,更清洁的方法?

I get a "Could not load SSL library" error message. 我收到“无法加载SSL库”错误消息。

Indy uses OpenSSL by default. Indy默认使用OpenSSL。 You can use Indy's WhichFailedToLoad() function in IdSSLOpenSSLHeaders.hpp to find out why it couldn't load the OpenSSL library. 您可以在IdSSLOpenSSLHeaders.hpp使用Indy的WhichFailedToLoad()函数来找出为什么它无法加载OpenSSL库的原因。

How do I tell IdHTTP1 to use SSL 如何告诉IdHTTP1使用SSL

You already are, by virtue of requesting an HTTP S url. 您已经可以通过请求HTTP S URL了。 Indy is simply having trouble loading the SSL library, either because it can't find the library binaries, or you have the wrong versions of the binaries. Indy只是在加载SSL库时遇到了麻烦,要么是因为找不到库二进制文件,要么是二进制文件的版本错误。 You can get Indy compatible OpenSSL binaries from https://indy.fulgan.com/SSL/ . 您可以从https://indy.fulgan.com/SSL/获得与Indy兼容的OpenSSL二进制文件。 Typically you should place them in the same folder as your app, but if you want to store them somewhere else then you need to call Indy's IdOpenSSLSetLibPath() function before invoking any SSL/TLS operations. 通常,您应该将它们放置在与应用程序相同的文件夹中,但是如果要将它们存储在其他位置,则需要在调用任何SSL / TLS操作之前调用Indy的IdOpenSSLSetLibPath()函数。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM