행위

Autoit curl

DB CAFE

thumb_up 추천메뉴 바로가기


https://www.autoitscript.com/forum/topic/162599-can-someone-please-show-me-how-to-use-curl-and-autoit/

2 autoit 적용 소스[편집]

Dim $iPidCurl = Run(@ComSpec & " /c " & 'curl -i -H' & 'Content-Type: application/x-www-form-urlencoded' & 'https://api.edmunds.com/inventory/token' & '-X POST -d ' & 'client_id=<MY SECRET ID >'&' -d ' & 'client_secret=<MY SECRET PHRASE>' & ' -d ' &'grant_type=client_credentials', @ScriptDir, @SW_HIDE,2+4)

Dim $sOut
While 1
    $sOut &= StdoutRead($iPidCurl)
    If @error Then ExitLoop
WEnd
While 1
    $sOut &= StderrRead($iPidCurl)
    If @error Then ExitLoop
WEnd
ConsoleWrite($sOut&@LF&"*********"&@LF)

3 curl 사용법[편집]

3.1 자주 사용하는 옵션 3가지[편집]

-d, --data: Send specified data in POST request. -H, --header: <header> Headers to supply with request. -X, --request: The request method to use. ex) GET, POST

[GET방식]

curl -d "key1=value1&key2=value2" \
-H "Content-Type: application/x-www-form-urlencoded" \
-X GET http://localhost:8000/data

[POST방식]

[URL형식 데이터]
curl -d "key1=value1&key2=value2" \
-H "Content-Type: application/x-www-form-urlencoded" \
-X POST http://localhost:8000/data
[JSON형식 데이터]
curl -d '{"key1":"value1", "key2":"value2"}' \
-H "Content-Type: application/json" \
-X POST http://localhost:8000/data
  1. 원도우 curl에서는 '를 "로 변경하고, "를 ""로 변경하고 호출해야한다.
curl -d "{""key1"":""value1"", ""key2"":""value2""}" \
-H "Content-Type: application/json" \
-X POST http://localhost:8000/data
~ $bidtest = "https://buy.auction.co.kr/buy/bidlist.aspx?ItemNo=C045907557"