zoukankan      html  css  js  c++  java
  • kepware http接口 OCaml

    读取某变量的值

    open Cohttp_lwt_unix
    open Cohttp
    open Lwt
    
    let uri = Uri.of_string "http://127.0.0.1:39321/iotgateway/read?ids=Channel1.Device1.tag1,Channel1.Device1.tag2" in
    let headers = Header.init ()
      |> fun h -> Header.add h "Connection" "keep-alive"
      |> fun h -> Header.add h "Cache-Control" "max-age=0"
      |> fun h -> Header.add h "Upgrade-Insecure-Requests" "1"
      |> fun h -> Header.add h "User-Agent" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.81 Safari/537.36"
      |> fun h -> Header.add h "Accept" "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8"
      |> fun h -> Header.add h "Accept-Encoding" "gzip, deflate, br"
      |> fun h -> Header.add h "Accept-Language" "zh-CN,zh;q=0.9"
      |> fun h -> Header.add h "cache-control" "no-cache"
    in
    
    Client.call ~headers `GET uri
    >>= fun (res, body_stream) ->
      (* Do stuff with the result *)

    列出所有变量

    open Cohttp_lwt_unix
    open Cohttp
    open Lwt
    
    let uri = Uri.of_string "http://127.0.0.1:39321/iotgateway/browse" in
    let headers = Header.init ()
      |> fun h -> Header.add h "Connection" "keep-alive"
      |> fun h -> Header.add h "Cache-Control" "max-age=0"
      |> fun h -> Header.add h "Upgrade-Insecure-Requests" "1"
      |> fun h -> Header.add h "User-Agent" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.81 Safari/537.36"
      |> fun h -> Header.add h "Accept" "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8"
      |> fun h -> Header.add h "Accept-Encoding" "gzip, deflate, br"
      |> fun h -> Header.add h "Accept-Language" "zh-CN,zh;q=0.9"
      |> fun h -> Header.add h "cache-control" "no-cache"
    in
    
    Client.call ~headers `GET uri
    >>= fun (res, body_stream) ->
      (* Do stuff with the result *)
  • 相关阅读:
    采用坐标变换(移动和旋转)画箭头
    学会Func
    一个链接器的实现
    linux内核skb操作
    终于实现samba可写不可删除
    删掉SafeDrv病毒(这个病毒有点意思)
    Writing a ServiceMain Function(使用RegisterServiceCtrlHandler函数)
    利用Winscp,Putty实现Windows下编写Linux程序
    联发科6亿美元将大陆子公司卖给四维图新(180个人价值6亿美元)
    TFTP:简单文本传输协议,BOOTP:引导程序协议
  • 原文地址:https://www.cnblogs.com/dXIOT/p/10626588.html
Copyright © 2011-2022 走看看