basyura's blog

あしたになったらほんきだす。

twibill.vim - twitter api wapper like a Rubytter.rb

https://github.com/basyura/twibill.vim

Rubytter.rb の vimscript 版。ハロウィンをガン無視して作ってみた。post 系のメソッドをサポートしてきれてないけど。

必要なもの

oauth - get access token

let ctx = twibill#access_token()
"
" open your browser to authenticate , and inpupt pin
"
echo ctx.access_token        "=> your access token
echo ctx.access_token_secret "=> your access token secret

get twibill instance

let twibill = twibill#new({
  \ 'access_token' : your access token, 
  \ 'access_token_secret' : your access token secret })

update status

call twibill.update('hello vim world')

home timeline

let xml = twibill.home_timeline()
for status in xml.childNodes('status')
  echo status.find('screen_name').value() . ' : ' . status.find('text').value()
endfor

mentions

let xml = twibill.mentions()
for status in xml.childNodes('status')
  echo status.find('screen_name').value() . ' : ' . status.find('text').value()
endfor

user timeline

let xml = twibill.user_timeline('basyura')
for status in xml.childNodes('status')
  echo status.find('screen_name').value() . ' : ' . status.find('text').value()
endfor

friends

let xml = twibill.friends('basyura')
for v in xml.findAll('screen_name')
  echo v.value()
endfor

show

let status = twibill.show('130596703198916610')
echo status.find('screen_name').value() . ' : ' . status.find('text').value()

list statuses

let xml = twibill.list_statuses('basyura', 'vim')
for status in xml.childNodes('status')
  echo status.find('screen_name').value() . ' : ' . status.find('text').value()
endfor

remove status

call twibill.remove_status('130580534530293761')

lists

let xml = twibill.lists('basyura')
for n in xml.findAll('full_name')
  echo n.value() "=> @basyura/list_name
endfor
for n in xml.findAll('name')
  echo n.value() "=> list_name
endfor

list members

let xml = twibill.list_members('basyura', 'vim')
for name in xml.findAll('screen_name')
  echo name.value()
endfor

favorites

let xml = twibill.favorites('basyura')
for status in xml.childNodes('status')
  echo status.find('screen_name').value() . ' : ' . status.find('text').value()
endfor

favorite

call twibill.favorite('130596703198916610')

remove favorite

call twibill.remove_favorite('130596703198916610')

retweet

call twibill.retweet('130597082212995072')