質問編集履歴

2

ソースコードの追加、補正

2020/07/16 14:23

投稿

shunki1023
shunki1023

スコア22

test CHANGED
File without changes
test CHANGED
@@ -12,7 +12,7 @@
12
12
 
13
13
  test()内にある配列をとってくるにはどうすればいいでしょう。
14
14
 
15
- ```ruby
15
+ ```ruby controllerにて
16
16
 
17
17
  require 'uri'
18
18
 
@@ -47,3 +47,9 @@
47
47
  result1 = response.body
48
48
 
49
49
  ```
50
+
51
+ ```ruby viewにて
52
+
53
+ <%= result1 %>
54
+
55
+ ```

1

ソースコードの挿入

2020/07/16 14:23

投稿

shunki1023
shunki1023

スコア22

test CHANGED
File without changes
test CHANGED
@@ -11,3 +11,39 @@
11
11
 
12
12
 
13
13
  test()内にある配列をとってくるにはどうすればいいでしょう。
14
+
15
+ ```ruby
16
+
17
+ require 'uri'
18
+
19
+ require 'net/http'
20
+
21
+ require 'openssl'
22
+
23
+
24
+
25
+ url = URI("https://community-open-weather-map.p.rapidapi.com/weather?callback=test&id=2172797&lang=Japan&units=%2522metric%2522%20or%20%2522imperial%2522&q=Osaka")
26
+
27
+
28
+
29
+ http = Net::HTTP.new(url.host, url.port)
30
+
31
+ http.use_ssl = true
32
+
33
+ http.verify_mode = OpenSSL::SSL::VERIFY_NONE
34
+
35
+
36
+
37
+ request = Net::HTTP::Get.new(url)
38
+
39
+ request["x-rapidapi-host"] = '指定された値'
40
+
41
+ request["x-rapidapi-key"] = '指定された値'
42
+
43
+
44
+
45
+ response = http.request(request)
46
+
47
+ result1 = response.body
48
+
49
+ ```