HTTP 协议框架

远程调用服务采用 HTTP 框架,部分协议需要验证调用者身份 ​
控制客户端调用格式

http方法:[POST或者GET] /命令路径 HTTP/1.1    
Host: 服务端 IP    
Connection: close    
Content-Length: 数据长度
其他参数: header
属性 说明
http方法 [POST 或者 GET] ,命令路径 HTTP/1.1
Host 服务端 IP
Port 端口号,触动精灵端口号为 50005,小精灵端口号为 50015(安卓 10 及以上系统端口号为 50055)
Connection close 不支持长链接,详见博客
Content-Length 数据长度
header 其他参数

Lua 示例代码

local response_body = {}
    http = require("socket.http")
    http.TIMEOUT=1
    local response_body = {}
    local rep , code = http.request{
        url = "http://192.168.0.2:50005/status",
        headers=   
        {  
            ["auth"] = Auth,  --触动专业版 iOS 无需写入验证串
        }, 
        sink = ltn12.sink.table(response_body),
    }

注意事项

  • 安卓标准版、iOS 标准版及 iOS 专业版必须有授权,授权为试用状态无法调用。
Copyright 北京帮你玩科技有限公司 2023 all right reserved,powered by Gitbook该文章修订时间: 2024-03-06 17:50:18

results matching ""

    No results matching ""