Skip to content

Instantly share code, notes, and snippets.

@erickgnavar
Created August 4, 2024 20:33
Show Gist options
  • Save erickgnavar/d4c132f300cdbf26d27d7f0e4c59a6dc to your computer and use it in GitHub Desktop.
Save erickgnavar/d4c132f300cdbf26d27d7f0e4c59a6dc to your computer and use it in GitHub Desktop.
(let ((url-request-method "POST")
(url-request-extra-headers `(("Content-Type" . "application/json") ("User-Agent" . "gist.el") ("Authorization" . ,(concat "Bearer " oauth-token))))
(url-request-data (json-encode payload)))
(url-retrieve "https://api.github.com/gists" 'my/gist-handle-response))))
(defun my/gist-handle-response (response)
"Process content of RESPONSE and extract link."
(let* ((status-line (buffer-substring-no-properties (line-beginning-position) (line-end-position)))
(status-code (nth 1 (split-string status-line " "))))
(message status-code)
(unless (not (string-equal status-code "201"))
(user-error "There was a problem with GitHub API, try again later"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment