Skip to content

Instantly share code, notes, and snippets.

@sachac sachac/Beeminder?
Created Mar 22, 2014

Embed
What would you like to do?
;; Totally untested
(defvar clarissa/beeminder-user "example" "Username for Beeminder service.")
(defvar clarissa/beeminder-token "1234" "Token - get this from https://www.beeminder.com/api/v1/auth_token.json")
(defun clarissa/beeminder-post (goal datapoint)
(interactive "MGoal: \nMData: \nMToken value: ")
(let ((url-request-data (json-encode `((value . ,datapoint) (auth_token . ,clarissa/beeminder-token))))
(url-request-method "POST")
(url-request-extra-headers '(("Content Type" . "application/json")))
(url-mime-encoding-string "identity"))
(condition-case nil
(url-retrieve-synchronously
(format "https://www.beeminder.com/users/%s/goals/%s/datapoints.json" clarissa/beeminder-user goal)))))
(defun clarissa/beeminder-org-update ()
(interactive)
(when (org-entry-get "GOAL")
(clarissa/beeminder-post (org-entry-get "GOAL") (or (org-entry-get "POINTS") (read-string "Points")))))
(add-hook 'org-after-todo-state-change-hook 'clarissa/beeminder-org-update)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.