1
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Ruby APIリクエスト Hash化への流れ

Last updated at Posted at 2017-07-22

今回は, Youtube Data APIを例にします.

require 'net/http'
require 'json'

# baseのURLを設定
uri = URI.parse 'https://www.googleapis.com/youtube/v3/search'

# リクエストの送信
uri.query = URI.encode_www_form({
  :q => "Ruby"
  :key => _api_key_
  :part => "snippet"
})
result = Net::HTTP.get(uri) 
res = JSON.parse(result)

# 取得結果を表示
p res

関数化して呼び出すと簡単に使えそう!

1
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?