diff options
author | Johnson Denen <johnson.denen@gmail.com> | 2018-03-05 22:09:37 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-03-05 22:09:37 -0500 |
commit | ae8dabda04e377a6ac22cb854e4844f68073f533 (patch) | |
tree | b6c875c5e88e72966440d3641ef37d320ee2d9fd /lisp/mastodon-http.el | |
parent | e08bb5794762d22f90e85fd65cef7c143e6b9318 (diff) | |
parent | e9920d64b5283fca6a34b2144a5a35c4c1d02938 (diff) |
Merge pull request #173 from jdenen/develop
Merge 0.7.2 into master
Diffstat (limited to 'lisp/mastodon-http.el')
-rw-r--r-- | lisp/mastodon-http.el | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/lisp/mastodon-http.el b/lisp/mastodon-http.el index 75cca2f..3240eef 100644 --- a/lisp/mastodon-http.el +++ b/lisp/mastodon-http.el @@ -2,7 +2,7 @@ ;; Copyright (C) 2017 Johnson Denen ;; Author: Johnson Denen <johnson.denen@gmail.com> -;; Version: 0.7.1 +;; Version: 0.7.2 ;; Package-Requires: ((emacs "24.4")) ;; Homepage: https://github.com/jdenen/mastodon.el @@ -31,7 +31,6 @@ (require 'json) (defvar mastodon-instance-url) -(defvar mastodon-auth--token) (autoload 'mastodon-auth--access-token "mastodon-auth") (defvar mastodon-http--api-version "v1") @@ -68,10 +67,10 @@ Open RESPONSE buffer if unsuccessful." (funcall success) (switch-to-buffer response)))) -(defun mastodon-http--post (url args headers) +(defun mastodon-http--post (url args headers &optional unauthenticed-p) "POST synchronously to URL with ARGS and HEADERS. -Authorization header is included by default." +Authorization header is included by default unless UNAUTHENTICED-P is non-nil." (let ((url-request-method "POST") (url-request-data (when args @@ -82,8 +81,10 @@ Authorization header is included by default." args "&"))) (url-request-extra-headers - `(("Authorization" . ,(concat "Bearer " mastodon-auth--token)) - ,headers))) + (append + (unless unauthenticed-p + `(("Authorization" . ,(concat "Bearer " (mastodon-auth--access-token))))) + headers))) (with-temp-buffer (url-retrieve-synchronously url)))) @@ -107,6 +108,7 @@ Pass response buffer to CALLBACK function." (decode-coding-string (buffer-substring-no-properties (point) (point-max)) 'utf-8))) + (kill-buffer) (json-read-from-string json-string))))) json-vector)) |