2011-05-13 6 views
3

AppleScript는 REST API와 상호 작용할 수있는 방법이 있습니까?Applescript + REST?

나는 그것은 올바른 코드를 생성하는 날 정말 도움이, 당신은 내가 postman를 추천 정확한 컬 문을 얻기 위해 도움이 필요하면 내가

do shell script "#curl script here" 

에 컬을

do shell script curl 
+2

'컬'을 사용하는 것이 좋습니다. – Simon

+1

당신이 말하는거야? http://developer.apple.com/library/mac/#documentation/AppleScript/Conceptual/soapXMLRPC/chapter1/soapXMLRPC_intro.html – regulus6633

+0

[AppleScript를 사용하여 XML 파일을 가져오고 구문 분석하는 방법] (http : // stackoverflow.com/questions/7280362/how-to-fetch-and-parse-an-xml-file-using-applescript) –

답변

3

사용합니다 수 있습니다 실현 . 하지만 기억이 있다면 : 앞에서 이스케이프 문자를 넣으십시오 : \".

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://api.widerstandsberechner.ch/api.php?firstcolor=red&secondcolor=orange&thirdcolor=yellow&fourthcolor=silver&hasFiveRings=0&resultInText=0 

에 POST 요청을 수행하려는 경우 :

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\"" 

희망이 있습니다.