开发者

curl on AppleScript

This is my script but I'm having problem on getting the response from the URL.

if newChromeValue contains "http://" then
        set URLChromerequest to "curl --url http://0.0.0.0:54321/cat?body=" & myBodyEnc & "&url=" & ¬
            newChromeValue & ¬
            "&title=" & ¬
            pgTitlEnc & ¬
            "&keywords=" & ¬
            mykeywordEnc & ¬
            "&description=" & ¬
            myDescriptionEnc & ¬
            "&type=body&reqtype=main/"

    else
        set URLChromerequest to "curl --url http://0.0.0.0:54321/cat?body=" & myBodyEnc & "&url=http://" & ¬
            newChromeValue & ¬
            "&title=" & ¬
            pgTitlEnc & ¬
            "&keywords=" & ¬
            mykeywordEnc & ¬
           开发者_如何学运维 "&description=" & ¬
            myDescriptionEnc & ¬
            "&type=body&reqtype=main/"

    end if



    set URLChromeResponse to do shell script URLChromerequest
    return URLChromeResponse

When I run this script , it shows that only the first parameter is sent over the server which is 'body'. The others seems to be missing...

however, if I return the 'URLChromerequest' I can see that the URL is form accordingly and if I paste it to the web browser, it works perfectly..

WHat might be the problem?


It might help to quote the url using quoted form of:

if newChromeValue does not start with "http://" then
    set newChromeValue to "http://" & newChromeValue
end

set URLChromerequest to "curl --url " & quoted form of ¬
    ("http://0.0.0.0:54321/cat?body=" & myBodyEnc & ¬
    "&url=" & newChromeValue & ¬
    "&title=" & pgTitlEnc & ¬
    "&keywords=" & mykeywordEnc & ¬
    "&description=" & myDescriptionEnc & ¬
    "&type=body" & ¬
    "&reqtype=main/")

set URLChromeResponse to do shell script URLChromerequest

Dont' know for sure though, but it would seem that the url is being split by the shell

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜