{"id":20732,"date":"2014-07-04T18:59:29","date_gmt":"2014-07-04T09:59:29","guid":{"rendered":"http:\/\/www.key-p.com\/blog\/staff\/?p=20732"},"modified":"2014-07-04T18:59:29","modified_gmt":"2014-07-04T09:59:29","slug":"webapi-vim%e3%82%92%e4%bd%bf%e3%81%84%e3%80%81api%e3%82%92%e5%8f%a9%e3%81%8f","status":"publish","type":"post","link":"https:\/\/www.key-p.com\/blog\/staff\/archives\/20732","title":{"rendered":"webapi-vim\u3092\u4f7f\u3044\u3001API\u3092\u53e9\u304f"},"content":{"rendered":"<p>\n\u6e9d\u7551\u3067\u3059\u3002  <br \/>\nMarkdown\u306e\u8a18\u4e8b\u3092\u66f8\u3044\u3066\u304b\u3089\u968f\u5206\u3068\u6642\u9593\u304c\u305f\u3063\u3066\u3057\u307e\u3044\u307e\u3057\u305f\u3002  <br \/>\n\u4eca\u56de\u306f<b>webapi-vim<\/b>\u3092\u4f7f\u7528\u3057\u3001API\u3092\u53e9\u3044\u3066\u307f\u3088\u3046\u3068\u3044\u3046\u5185\u5bb9\u3067\u3059\u3002  <br \/>\n<h3>webapi-vim\u3068\u306f<\/h3>\nVim\u304b\u3089\u3001HTTP\u306ePOST\u3084GET\u304c\u3067\u304d\u308b\u3001\u975e\u5e38\u306b\u4fbf\u5229\u306a\u30d7\u30e9\u30b0\u30a4\u30f3\u3067\u3059\u3002  <br \/>\n<a href='https:\/\/github.com\/mattn\/webapi-vim' target='blank'>webapi-vim<\/a><br \/>\n<h3>\u5c0e\u5165<\/h3>\n\u30d7\u30e9\u30b0\u30a4\u30f3\u7ba1\u7406\u306b<b>NeoBundle<\/b>\u3092\u4f7f\u7528\u3057\u3066\u3044\u308b\u3053\u3068\u3092\u524d\u63d0\u3068\u3057\u307e\u3059\u3002<br \/>\n.vimrc\u306b\u4e0b\u8a18\u3092\u8ffd\u8a18\u3057\u307e\u3059\u3002<br \/>\n<pre class=\"lang:vim decode:true \" title=\".vimrc\" >NeoBundle 'mattn\/webapi-vim'<\/pre>\n\u3042\u3068\u306f\u3001<b>:NeoBundleInstall<\/b>\u306e\u30b3\u30de\u30f3\u30c9\u3092\u53e9\u304f\u3068\u5c0e\u5165\u5b8c\u4e86\u3067\u3059\u3002<br \/>\n<h3>\u4f7f\u3044\u65b9<\/h3>\n<pre class=\"lang:vim decode:true \" title=\".vimrc\" >\"get\u306e\u5834\u5408\nlet res = webapi#http#get('URL')\n\n\"post\u306e\u5834\u5408\nlet res= webapi#http#post('URL')\n\n\"json\u3092\u30c7\u30b3\u30fc\u30c9\u3059\u308b\nlet content = webapi#json#decode(res.content)\n\n\"echo\u3059\u308b\necho content<\/pre>\nPOST\u3084GET\u3092\u3059\u308b\u3060\u3051\u306a\u3089\u3070\u3001\u3053\u306e\u3088\u3046\u306b\u66f8\u304f\u3068\u4f7f\u3046\u3053\u3068\u304c\u53ef\u80fd\u3067\u3059\u3002\u3068\u3066\u3082\u7c21\u5358\u3002<br \/>\n\u305d\u306e\u4ed6\u3001\u8a73\u3057\u3044\u4f7f\u3044\u65b9\u306f\u30d8\u30eb\u30d7\u3092\u53c2\u7167\u3057\u3066\u304f\u3060\u3055\u3044\u3002<br \/>\n<h3>\u30c1\u30e3\u30c3\u30c8\u30ef\u30fc\u30af\u306b\u6295\u7a3f\u3057\u3066\u307f\u308b<\/h3>\n\u30b5\u30f3\u30d7\u30eb\u3068\u3057\u3066\u3001Vim\u304b\u3089\u30c1\u30e3\u30c3\u30c8\u30ef\u30fc\u30af\u306b\u6295\u7a3f\u3059\u308b\u30b3\u30de\u30f3\u30c9\u3092\u4f5c\u6210\u3057\u3066\u307f\u307e\u3057\u305f\u3002  <br \/>\n <br \/>\n<pre class=\"lang:vim decode:true \" title=\".vimrc\" >\" command\u4f5c\u6210\ncommand! -nargs=1 ChatWorkSay :call s:ChatWorkSay(&lt;f-args&gt;)\n\n\" \u95a2\u6570\nfunction! s:ChatWorkSay(message)\n  let token = 'API\u306e\u30c8\u30fc\u30af\u30f3'\n  let room_id = '\u6295\u7a3f\u3059\u308broom_id'\n  let url = 'https:\/\/api.chatwork.com\/v1\/rooms\/'. room_id\n\n  \" message\u3092POST\u3059\u308b\n  let res = webapi#http#post(url. '\/messages', {'body': a:message},\n    \\ {'X-ChatWorkToken': token})\n\n  let dict = webapi#json#decode(res.content)\n  \" message_id\u3092echo\n  echo dict.message_id\nendfunction<\/pre>\ntoken\u3068room_id\u306f\u3054\u81ea\u8eab\u306e\u3082\u306e\u3092\u5165\u308c\u3066\u304f\u3060\u3055\u3044\u3002<br \/>\n<b>:ChatWorkSay hogehoge<\/b>\u3068\u3059\u308b\u3053\u3068\u3067\u3001\u6295\u7a3f\u3059\u308b\u3053\u3068\u304c\u53ef\u80fd\u306b\u306a\u308a\u307e\u3059\u3002<br \/>\n\u30a8\u30e9\u30fc\u51e6\u7406\u306a\u3069\u3092\u8ffd\u52a0\u3059\u308b\u3068\u3001\u4f7f\u3044\u3084\u3059\u304f\u306a\u308a\u305d\u3046\u3067\u3059\u304c\u3001\u30b5\u30f3\u30d7\u30eb\u3067\u3059\u306e\u3067\u4eca\u56de\u306f\u306a\u3057\u3067\u3059\u3002<br \/>\n<br \/>\n\u52d5\u4f5c\u30a4\u30e1\u30fc\u30b8\u3067\u3059\u3002<br \/>\n<a href=\"http:\/\/www.key-p.com\/blog\/staff\/wp-content\/uploads\/2014\/07\/chatworksay.mov.gif\"><img loading=\"lazy\" src=\"http:\/\/www.key-p.com\/blog\/staff\/wp-content\/uploads\/2014\/07\/chatworksay.mov.gif\" alt=\"chatworksay.mov\" width=\"600\" height=\"400\" class=\"alignnone size-full wp-image-20741\" \/><\/a><br \/>\n<h3>\u6700\u5f8c\u306b<\/h3>\nVim script\u3092\u66f8\u3044\u3066\u307f\u305f\u3044\u3051\u3069\u3001\u30cd\u30bf\u304c\u601d\u3044\u3064\u304b\u306a\u3044\u3002<br \/>\n\u305d\u3093\u306a\u65b9\u306b\u30d4\u30c3\u30bf\u30ea\u3067\u306f\u306a\u3044\u3067\u3057\u3087\u3046\u304b\u3002<br \/>\nAPI\u3092\u53e9\u3051\u308b\u3060\u3051\u3067\u3001Vim\u3092\u4fbf\u5229\u306b\u3059\u308b\u5e45\u304c\u5e83\u304c\u308a\u307e\u3059\u3002<br \/>\n<br \/>\n\u662f\u975e\u3001\u8a66\u3057\u3066\u307f\u3066\u304f\u3060\u3055\u3044\u3002<br \/>\nVim \u4fbf\u5229\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6e9d\u7551\u3067\u3059\u3002 Markdown\u306e\u8a18\u4e8b\u3092\u66f8\u3044\u3066\u304b\u3089\u968f\u5206\u3068\u6642\u9593\u304c\u305f\u3063\u3066\u3057\u307e\u3044\u307e\u3057\u305f\u3002  &hellip; <a href=\"https:\/\/www.key-p.com\/blog\/staff\/archives\/20732\">\u7d9a\u304d\u3092\u8aad\u3080 <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":33,"featured_media":20741,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[23],"tags":[],"jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/www.key-p.com\/blog\/staff\/wp-json\/wp\/v2\/posts\/20732"}],"collection":[{"href":"https:\/\/www.key-p.com\/blog\/staff\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.key-p.com\/blog\/staff\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.key-p.com\/blog\/staff\/wp-json\/wp\/v2\/users\/33"}],"replies":[{"embeddable":true,"href":"https:\/\/www.key-p.com\/blog\/staff\/wp-json\/wp\/v2\/comments?post=20732"}],"version-history":[{"count":13,"href":"https:\/\/www.key-p.com\/blog\/staff\/wp-json\/wp\/v2\/posts\/20732\/revisions"}],"predecessor-version":[{"id":20746,"href":"https:\/\/www.key-p.com\/blog\/staff\/wp-json\/wp\/v2\/posts\/20732\/revisions\/20746"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.key-p.com\/blog\/staff\/wp-json\/wp\/v2\/media\/20741"}],"wp:attachment":[{"href":"https:\/\/www.key-p.com\/blog\/staff\/wp-json\/wp\/v2\/media?parent=20732"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.key-p.com\/blog\/staff\/wp-json\/wp\/v2\/categories?post=20732"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.key-p.com\/blog\/staff\/wp-json\/wp\/v2\/tags?post=20732"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}