Can't get cURL working with RTM API

6 views
Skip to first unread message

Roopesh Sheth

unread,
Feb 20, 2008, 2:21:42 PM2/20/08
to Remember The Milk API
I am trying to develop an app to create tasks (specifically using
Entourage). I am working in AppleScript.

When I do an "open location ..." to the api (currently trying to do an
rtm.auth.getFrob), my browser pops open and I see the XML response, it
is successful.

However, when I try to use curl (do shell script "curl ...") I get
back a message from RTM saying the api_key is invalid.

I'm using the exact same request for both calls. I created a
requestTxt variable and use the variable for both calls.

Anyone seen this before?

Thanks

Applescript code snippet:

on getRTMfrob()
set sig to RTMapi_secret
set sig to sig & "api_key" & RTMapi_key
set sig to sig & "methodrtm.auth.getFrob"
do shell script "/sbin/md5 -qs " & sig
set md5sig to result
set requestTxt to "http://api.rememberthemilk.com/services/rest/?
method=rtm.auth.getFrob"
set requestTxt to requestTxt & "&api_key=" & urlEncode(RTMapi_key)
set requestTxt to requestTxt & "&api_sig=" & urlEncode(md5sig)
--display alert md5sig
--display alert requestTxt

do shell script "curl " & requestTxt
set frobXML to result
display alert frobXML

--set frobXML to open location requestTxt
--set frobXML to result
--display alert frobXML
end getRTMfrob

Roopesh Sheth

unread,
Feb 20, 2008, 2:38:20 PM2/20/08
to Remember The Milk API
Ah, found the solution. Had to escape the "&" character with "\\".
Updated code:

Roopesh Sheth

unread,
Feb 20, 2008, 4:33:26 PM2/20/08
to Remember The Milk API
Hah! A better way to do this:

do shell script "curl \"" & requestTxt & "\""

No need for the "\\" anymore at all, since the entire request is sent
inside the quotes.
Reply all
Reply to author
Forward
0 new messages