Skip to content

Instantly share code, notes, and snippets.

@dg01d
Created February 24, 2018 13:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dg01d/9879ed8e7cb3302908294cee46788acc to your computer and use it in GitHub Desktop.
Save dg01d/9879ed8e7cb3302908294cee46788acc to your computer and use it in GitHub Desktop.
Micropub using emacs

Credits

This is just an amendment for hjertnes' script

Notes

  • The setting mb-domain should be set to the full path of the micropub endpoint.
  • I could not get this to work using form-encoded post format. If your endpoint does not support json-encoded posts, this will likely not work.
(require 'request)
(defun post2mb ()
(interactive)
(if (yes-or-no-p "Are you sure you want to post this?" )
(request
mb-domain
:type "POST"
:data (json-encode `((type . ["h-entry"]) (properties (content . [,(buffer-substring-no-properties (point-min) (point-max))]))))
:headers `(("Content-Type" . "application/json") ("Authorization".,(format "Bearer %s" mb-auth)))
:success (cl-function
(lambda (&key data &allow-other-keys)
(message "Success")))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment