回答編集履歴

1

追記

2017/06/27 04:34

投稿

shi_ue
shi_ue

スコア4437

test CHANGED
@@ -5,3 +5,101 @@
5
5
  var hexHash = SparkMD5.hash('Hi there');
6
6
 
7
7
  ```と同じ方法でハッシュ出来そうですけど?
8
+
9
+
10
+
11
+ 追記
12
+
13
+ ---
14
+
15
+ 検証コードを作ってみました。
16
+
17
+ `test.php`
18
+
19
+ ```php
20
+
21
+ <?php
22
+
23
+ header("Content-type: application/json; charset=utf-8");
24
+
25
+ // Livedoorお天気Webサービス
26
+
27
+ // http://weather.livedoor.com/weather_hacks/webservice
28
+
29
+ echo file_get_contents("http://weather.livedoor.com/forecast/webservice/json/v1?city=130010");
30
+
31
+ ```
32
+
33
+ `test.html`
34
+
35
+ ```html
36
+
37
+ <!DOCTYPE html>
38
+
39
+ <html>
40
+
41
+ <head>
42
+
43
+ <meta charset="utf-8">
44
+
45
+ <title></title>
46
+
47
+ <style>
48
+
49
+ * {box-sizing:border-box;}
50
+
51
+ #rawData {width:800px;height:300px}
52
+
53
+ #hash {width:400px;}
54
+
55
+ </style>
56
+
57
+ <script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
58
+
59
+ <script src="spark-md5.min.js"></script>
60
+
61
+ <script>
62
+
63
+ $(function(){
64
+
65
+ $.ajax({
66
+
67
+ cache: false,
68
+
69
+ dataType: "text",
70
+
71
+ url: 'test.php',
72
+
73
+ type: 'GET',
74
+
75
+ success: function(data) {
76
+
77
+ $('#rawData').val(data);
78
+
79
+ var hexHash = SparkMD5.hash(data);
80
+
81
+ $('#hash').val(hexHash);
82
+
83
+ }
84
+
85
+ });
86
+
87
+ });
88
+
89
+ </script>
90
+
91
+ </head>
92
+
93
+ <body>
94
+
95
+ <p><textarea id="rawData"></textarea></p>
96
+
97
+ <p><input type="text" id="hash"></p>
98
+
99
+ </body>
100
+
101
+ </html>
102
+
103
+ ```天気予報が変わるまでは、同じハッシュが返ります。
104
+
105
+ キャッシュをクリアしても同じ値になるので、同じJSONだと確認できます。