语法
HttpPost(context: any, url: string, body?: string, contentTypeOrCompatibility?: string | number | boolean, headersOrContentType?: table | string, headers?: table): string参数
| 名称 | 类型 | 描述 |
|---|---|---|
context | any | 调用方法样式帮助器时提供的自身或上下文参数。 |
url | string | 要连接的 HTTP 或 WebSocket URL。 |
body? | string | 请求正文随 HTTP 请求一起发送。 |
contentTypeOrCompatibility? | string | number | boolean | 旧版 HttpPost 签名的内容类型或兼容性标志。 |
headersOrContentType? | table | string | 标头表或内容类型值,具体取决于调用样式。 |
headers? | table | 随请求一起发送的 HTTP 标头。 |
返回值
| 名称 | 类型 | 描述 |
|---|---|---|
body | string | HTTP 响应正文。 |
说明
发送 POST 请求并返回响应正文。
使用 6 个参数调用: context, url, body, contentTypeOrCompatibility, headersOrContentType, headers。参数表会说明哪些值必填,哪些值只用于细化行为。
返回 body (string)。使用返回表区分成功值、nil 结果和可恢复错误。
示例
使用占位值的示例调用。
local result = HttpPost(nil, "example", "example", "example", "example", {})
print(result)