Posted at

qiita gemを使ってみたメモ

More than 5 years have passed since last update.

明日のQiita HackerthonにあわせてQiita gemを使ってみました。

# coding: utf-8                                               

require 'rubygems'
require 'qiita'

# use name and password
qiita = Qiita.new( url_name: 'username', password: 'password')

# Get token
p token = qiita.token

# use token
qiita = Qiita.new token: qiita.token

# Get userinfo
p u = qiita.user(qiita.url_name)
u.url_name
u.description

qiita.user_items.each do |item|
p item.uuid
article = qiita.item item.uuid

p "Titleがとれます -----------------"
p "title: #{article.title}"
p "markdownがとれます-----------------"
p "title: #{article.raw_body}"
end