【问题标题】:JXA for automation: url encoding for get request自动化的 JXA:获取请求的 url 编码
【发布时间】:2019-08-04 14:10:31
【问题描述】:

我正在尝试通过 get 请求向我的服务器发送文本,但我在处理空格/特殊字符时遇到了一些困难。

如何对请求的文本进行编码?

(以及如何在php中解码?)

这是我的代码:

var app = Application.currentApplication();
app.includeStandardAdditions = true;

var text = app.displayDialog("enter your text:", { defaultAnswer: "" }).textReturned;

var result = JSON.parse(app.doShellScript('curl https://example.com?text=' + text));


result

【问题讨论】:

    标签: urlencode javascript-automation


    【解决方案1】:

    嗯,看来我自己找到了答案:

    encodeURIComponent(text)
    

    似乎对我有用。不需要PHP解码。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-08-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-02-10
      • 1970-01-01
      • 2021-01-23
      • 1970-01-01
      相关资源
      最近更新 更多