AsyncGetToString 和 AsyncPostFromString 之间的区别?

Difference between AsyncGetToString and AsyncPostFromString?

我创建了一个网站 API。我打电话给明亮的脚本。我参考 https://developer.roku.com/en-gb/docs/references/brightscript/interfaces/ifurltransfer.md#head-as-dynamic/ 所有方法但不了解任何人都知道它对 AsyncGetToString 和 AsyncPostFromString 方法的真正用途。

我在 Roku 中使用以下代码

readInternet = createObject("roUrlTransfer")
      readInternet.setUrl(url)
      readInternet.setport(m.port)

      readInternet.gettostring()
      timer = createobject("roTimeSpan")
      timer.Mark()
      readInternet.AsyncPostFromString() 'readInternet.AsyncGetToString

但它每次都会在我的 Roku 服务器中触发 Get 方法。

这里是 Roku 服务器代码(使用 Get 方法)

public string Get(int id)
{
            return "The vlaue is: " + id;
}

它总是双向调用这个方法 (使用 Post 方法)

 [HttpPost] // OWIN - Open Web Interface for .NET
 public HttpResponseMessage Post([FromUri]string name, [FromUri]string pass) // Its use both FromBody (complex type from the query string) and FromUri(primitive type from the request body)
 {
      //return "UserName Details :" + name + pass;
      return Request.CreateResponse(HttpStatusCode.OK, name + " " + pass); //Using Post Method
 }

请任何人帮助我。

AsyncPostFromString() 允许您发出异步 POST 请求,该请求一旦完成就会将消息发送到与其关联的消息端口(在本例中为 m.port)。

m.port = createObject("roMessagePort")
readInternet = createObject("roUrlTransfer")
readInternet.setUrl(url)
readInternet.setMessagePort(m.port)
if readInternet.asyncPostFromString("your_post_data_string") then
    msg = m.port.waitMessage(0)
    if type(msg) = "roUrlEvent" then
        print msg
    end if
end if

这应该向您的服务器端点发出正确的 POST 请求。请注意,您需要将 POST 数据作为参数传递给 asyncPostFromString()