Old question, yes... But in the event that anyone Googles this; another option is using Org Babel and
ob-http... (Can be installed from melpa.)
org-babel, you can make an
.org file containing "
http" code blocks. When these blocks are evaluated, they will make the HTTP request and return the response as the result.
If these blocks have a "
#+NAME:" attribute, you can use their results in any other
org-babel block. This allows for some pretty neat literate programming using the results of HTTP requests.
For example, here is a little Org document demonstrating making an HTTP request and parsing the returned JSON in Ruby:
* The request
The following is the example request shown on [[https://github.com/zweifisch/ob-http][ob-http's Github page]]...
It isn't anything fancy, but it is a REST API request, and returns
JSON, so it works for the sake of this demonstration:
#+BEGIN_SRC http :pretty
: "Emacs Lisp": 7034
Notice how this has a "=#+NAME:=" attribute? This is a name we can use
in other =org-babel= blocks. (As you will see below)
* Using the request
Now that I have an =http= request in an org block with a name... Lets
write something in a completely different language and use our HTTP
#+BEGIN_SRC ruby :var langs=ob-languages
The =:var= keyword allowed me to assign the "=langs=" variable in the
Ruby block to the result of the =ob-languages= block [[The request][above]].
This didn't have to be in Ruby, this could have been any language,
including another =http= block.
This is what this looks like in
C-c C-c on the bottom block (The Ruby one) will automagically evaluate the top one for its dependency (That's the
:var bit in the block's header.). This will mean that the
http request is made first, and then the results are passed to Ruby for further processing.
You can do this with as many blocks as you like and with as many languages.
If this suits your needs,
ob-http requires a little bit of manual tweaking after you install it to get it working. (Don't worry, it isn't that much)
ob-http, you need to customize two variables:
So, by running
M-x customize-variable, you can customize each to include the following:
You will want to customize this variable to include one more language mapping, so you can insert one more value to the end of the list:
Then you can
C-x C-s to save that customization.
You will want to add one more item to the list of enabled
org languages. "
Though, you might need to add it to the list manually if the option is not in the possible options, you can do that by clicking "State" and choosing "
:" to show the Lisp expression... Then you would add the following just before the last closing parenthesis:
(http . t)
After that, a quick
C-x C-s and
M-x org-reload should be all you need..!