Интеграция в другие системы/en — различия между версиями
(Новая страница: «Integration into other systems») |
(Новая страница: «WebHMI allows you to interact with other systems by running HTTP requests. For this, WebHMI has a library [https://github.com/Lua-cURL/Lua-cURLv3 Lua-cURLv3]. Usi…») |
||
Строка 1: | Строка 1: | ||
<languages/> | <languages/> | ||
− | WebHMI | + | WebHMI allows you to interact with other systems by running HTTP requests. For this, WebHMI has a library [https://github.com/Lua-cURL/Lua-cURLv3 Lua-cURLv3]. |
+ | Using it you can easily send data to third-party systems and also request the necessary data from these systems. | ||
Данная функция доступна начиная с версии 2.6.4520. | Данная функция доступна начиная с версии 2.6.4520. |
Версия 13:44, 21 ноября 2017
WebHMI allows you to interact with other systems by running HTTP requests. For this, WebHMI has a library Lua-cURLv3. Using it you can easily send data to third-party systems and also request the necessary data from these systems.
Данная функция доступна начиная с версии 2.6.4520.
Пример программы, выполняющей HTTPS-запрос для отправки данных виде файла на URL https://demo.com/upload:
function main (userId)
INFO("Doing CURL");
c = cURL.easy_init()
c:setopt_url("https://demo.com/upload")
postdata = {
name = {
file="dummy.html",
data="<html><bold>bold</bold></html>",
type="text/html"
}
}
c:post(postdata)
c:perform()
c:close()
INFO("CURL done");
end
Обратите внимание, что для корректной работы SSL-сертификатов необходимо иметь точное локально время. При значительном отклонении локальных часов, https-запросы могут не работать. Рекомендуем использовать синхронизацию времени по NTP-серверу.
Пример запроса числа по GET-запросу с URL http://demo.example.com/read-data?param=32 и записи его в регистр с id=4356:
function main (userId)
c = cURL.easy_init()
c:setopt_url("http://demo.example.com/read-data?param=32")
local res = "";
c:perform({
writefunction = function(str)
res = res .. str;
end})
c:close()
WriteReg(4356, res);
end