-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadd_list_item.scpt
32 lines (28 loc) · 1.44 KB
/
add_list_item.scpt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
on handle_string(theText)
set apiKey to "YOUR_API_KEY"
set yourUser to "YOUR_ACCOUNT_NAME"
set backpackPage to "BACKPACK_PAGE_ID"
set listID to "BACKPACK_LIST_ID"
set SSL to "no"
if SSL = "yes" then
set identifier to "https://"
else
set identifier to "http://"
end if
set text item delimiters to ":"
set theItems to text items of theText
set text item delimiters to ""
set itemCount to count of theItems
if itemCount = 2 then
set titleText to item 1 of theItems
set bodyText to item 2 of theItems
set CurlScript to "curl -H 'Content-Type: application/xml' -H 'X-BP-Token:" & apiKey & "' -d '<request><item><content>" & titleText & "</content></item></request>' " & identifier & yourUser & ".backpackit.com/ws/page/" & backpackPage & "/lists/" & listID & "/items/add/"
set CurlScript2 to "curl -H 'Content-Type: application/xml' -d '<request><token>" & apiKey & "</token><note><title>" & titleText & "</title><body>" & bodyText & "</body></note></request>' " & identifier & yourUser & ".backpackit.com/ws/page/" & backpackPage & "/notes/create"
else
set bodyText to theText
set CurlScript to "curl -H 'Content-Type: application/xml' -H 'X-BP-Token:" & apiKey & "' -d '<request><item><content>" & bodyText & "</content></item></request>' " & identifier & yourUser & ".backpackit.com/ws/page/" & backpackPage & "/lists/" & listID & "/items/add/"
end if
do shell script CurlScript
do shell script CurlScript2
return null
end handle_string