-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadd_note.scpt
29 lines (25 loc) · 1.1 KB
/
add_note.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
on handle_string(theText)
set apiKey to "YOUR_API_KEY"
set yourUser to "YOUR_ACCOUNT_NAME"
set backpackPage to "BACKPACK_PAGE_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' -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' -d '<request><token>" & apiKey & "</token><note><title></title><body>" & bodyText & "</body></note></request>' " & identifier & yourUser & ".backpackit.com/ws/page/" & backpackPage & "/notes/create"
end if
do shell script CurlScript
return null
end handle_string