Open the AppleScript Editor on your Mac, paste this in to a new script:
property theUsername : "your username"
property thePassword : "your password"
property theURL : "https://www.xpenser.com/api/v1.0/expense/"
property theQueryTimeout : 10
property theDefaultQuery : "Lunch 12.14 ModMarket with Marcus #clientX"
on postExpense(theQuery)
set XpenserUpdate to "/usr/bin/curl -s -S -m " & theQueryTimeout & ¬
" -u " & quoted form of (theUsername & ":" & thePassword) & ¬
" -d " & quoted form of ("q=" & theQuery) & ¬
" " & quoted form of theURL
set XpenserResponse to do shell script XpenserUpdate
if XpenserResponse contains "\"status\": 1" then
return "Your expense was saved."
else
return "There was a problem saving your expense!"
end if
end postExpense
set theResult to display dialog "Add A New Expense" default answer theDefaultQuery
set theQuery to text returned of theResult
set theButton to button returned of theResult
if theButton is equal to "OK" and theQuery is not equal to theDefaultQuery then
set theResponse to postExpense(theQuery)
say theResponse
else
-- do nothing
end if
Then update your username and password and save as an application in your applications folder (I called it SendToXpenser).

Now you can type apple-space to open Spotlight type SendToXpenser and press return.

You are prompted for quick entry text and you get voice confirmation if the expense was added or not.

Advertisement
If you want to launch this with a keyboard shortcut, you can create a service with automator. Setup no input and use the run applescript action to run this (remember to update your username and password.) Then in System Preferences -> Keyboard you can assign a keyboard shortcut to this service.
I’m not sure whether placing the content of the script directly in the service (Automator) would work for the growl notification version I posted below…
But what does work is saving the script as an Application (via the original instructions above) and then using the following script in the service (Automator)
on run {input, parameters} do shell script "open /Applications/SendToExpenser.app" return input end runEven if you don’t use the Growl version, it’d make it a bit easier to modify the AppleScript in the future. E.G. When you change your password.
[...] (creator of the Fresh Xpense Capture iPhone app) has come up with another fantastic little helper: an OS X app that allows very simple expense capture, with voice [...]
Thank you. This is a huge help!
Is there any chance you might be able to add the ability to drag a file to the applescipt icon and it would upload the receipt along with the query string?
I’m certain that is possible. I don’t currently have time to work on this. Hope someone else will stop by and do it. :) In any case I’ll add it to my possible future project list.
I created a variation of your script that sends a Growl alert rather than saying the response. Note: Unless you modify the script, you MUST save it as SendToExpenser
property theUsername : "your username" property thePassword : "your password" property theURL : "https://www.xpenser.com/api/v1.0/expense/" property theQueryTimeout : 10 property theDefaultQuery : "Lunch 12.14 ModMarket with Marcus #clientX" on postExpense(theQuery) set XpenserUpdate to "/usr/bin/curl -s -S -m " & theQueryTimeout & ¬ " -u " & quoted form of (theUsername & ":" & thePassword) & ¬ " -d " & quoted form of ("q=" & theQuery) & ¬ " " & quoted form of theURL set XpenserResponse to do shell script XpenserUpdate if XpenserResponse contains "\"status\": 1" then return "Sucess" else return "Error" end if end postExpense on sendGrowl(theResponse) tell application "GrowlHelperApp" set the allNotificationsList to ¬ {"Sucess", "Error"} set the enabledNotificationsList to ¬ {"Sucess", "Error"} register as application ¬ "SendToXpenser" all notifications allNotificationsList ¬ default notifications enabledNotificationsList ¬ icon of application "Script Editor" if theResponse is equal to "Sucess" then notify with name ¬ "Sucess" title ¬ "Xpenser, Yay!" description ¬ "Go Go Xpenser Gadget" application name ¬ "SendToXpenser" else notify with name ¬ "Error" title ¬ "Xpenser, Nay!" description ¬ "There be Xpenser Dragons" application name ¬ "SendToXpenser" end if end tell end sendGrowl set theResult to display dialog "Add A New Expense" default answer theDefaultQuery set theQuery to text returned of theResult set theButton to button returned of theResult if theButton is equal to "OK" and theQuery is not equal to theDefaultQuery then set theResponse to postExpense(theQuery) --say theResponse sendGrowl(theResponse) else -- do nothing end ifCool idea, thanks for sharing!
There were some copy and paste issues. The code above needs a bit of clean up. E.G. & needs to be &, line 3 should be:
Foiled again… “& amp;” should just be &. And the anchor tag needs to be stripped out of the theURL.