いかたけの備忘録

忘れっぽい

suzuriのAPIをrubyで触る

suzuriのAPIrubyで触る

#!/bin/ruby

require 'json';
require 'faraday'

conn = Faraday::Connection.new(:url => 'https://suzuri.jp/') do
|builder|
  builder.use Faraday::Request::UrlEncoded
  builder.use Faraday::Response::Logger
  builder.use Faraday::Adapter::NetHttp
end

response = conn.get do |request|
  request.url  'api/v1/activities'
  request.headers['Authorization'] = 'Bearer (略)'
  request.headers['Content-Type'] = 'application/json'
end
json = JSON.parser.new(response.body)
p json.parse

そういった感じでした。