Vim から wandbox の API を叩いてみた
何かと話題の wandbox ですが API を使ってみたかったのでとりあえず Vim から叩いてみました。
webapi.vim を使用して以下のような感じに。
[ソース]
function! s:wandbox_compile(code) let post_code = '{ \ "code": "' . a:code . '", \ "options": "warning,gnu++1y", \ "compiler": "gcc-head", \}' let result = webapi#http#post("http://melpon.org/wandbox/api/compile.json", \ post_code, \ { "Content-type" : "application/json" }, \) let content = webapi#json#decode(result.content) echo content endfunction function! s:main() let code = '#include <iostream>\nint main() { std::cout << \"hello, world\"; }' call s:wandbox_compile(code) endfunction call s:main()
[出力]
{'status': '0', 'program_output': 'hello, world', 'program_message': 'hello, world'}