AppleScript是否有与REST API交互的方式?
我意识到我可以
do shell script curl发布于 2016-11-11 04:19:44
我会使用curl in
do shell script "#curl script here"如果您需要帮助来获得正确的curl语句,我推荐使用postman,它真的可以帮助我生成正确的代码。但是请记住,如果你有这些:在前面放一个转义字符的":\"。
例如,如果我想做一个POST请求
https://api.widerstandsberechner.ch/api.php?firstcolor=red&secondcolor=orange&thirdcolor=yellow&fourthcolor=silver&hasFiveRings=0&resultInText=0AppleScript将如下所示:
do shell script "curl -X POST -H \"Cache-Control: no-cache\" \"https://api.widerstandsberechner.ch/api.php?firstcolor=red&secondcolor=orange&thirdcolor=yellow&fourthcolor=silver&hasFiveRings=0&resultInText=0\""当然,您可以很容易地将结果赋值:
set res to do shell script "curl -X POST -H \"Cache-Control: no-cache\" \"https://api.widerstandsberechner.ch/api.php?firstcolor=red&secondcolor=orange&thirdcolor=yellow&fourthcolor=silver&hasFiveRings=0&resultInText=0\""希望这能有所帮助!
https://stackoverflow.com/questions/5998789
复制相似问题