回答編集履歴
1
追記
answer
CHANGED
@@ -1,4 +1,53 @@
|
|
1
1
|
ajaxでjsonを読み込むなら、
|
2
2
|
```javascript
|
3
3
|
var hexHash = SparkMD5.hash('Hi there');
|
4
|
-
```と同じ方法でハッシュ出来そうですけど?
|
4
|
+
```と同じ方法でハッシュ出来そうですけど?
|
5
|
+
|
6
|
+
追記
|
7
|
+
---
|
8
|
+
検証コードを作ってみました。
|
9
|
+
`test.php`
|
10
|
+
```php
|
11
|
+
<?php
|
12
|
+
header("Content-type: application/json; charset=utf-8");
|
13
|
+
// Livedoorお天気Webサービス
|
14
|
+
// http://weather.livedoor.com/weather_hacks/webservice
|
15
|
+
echo file_get_contents("http://weather.livedoor.com/forecast/webservice/json/v1?city=130010");
|
16
|
+
```
|
17
|
+
`test.html`
|
18
|
+
```html
|
19
|
+
<!DOCTYPE html>
|
20
|
+
<html>
|
21
|
+
<head>
|
22
|
+
<meta charset="utf-8">
|
23
|
+
<title></title>
|
24
|
+
<style>
|
25
|
+
* {box-sizing:border-box;}
|
26
|
+
#rawData {width:800px;height:300px}
|
27
|
+
#hash {width:400px;}
|
28
|
+
</style>
|
29
|
+
<script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
|
30
|
+
<script src="spark-md5.min.js"></script>
|
31
|
+
<script>
|
32
|
+
$(function(){
|
33
|
+
$.ajax({
|
34
|
+
cache: false,
|
35
|
+
dataType: "text",
|
36
|
+
url: 'test.php',
|
37
|
+
type: 'GET',
|
38
|
+
success: function(data) {
|
39
|
+
$('#rawData').val(data);
|
40
|
+
var hexHash = SparkMD5.hash(data);
|
41
|
+
$('#hash').val(hexHash);
|
42
|
+
}
|
43
|
+
});
|
44
|
+
});
|
45
|
+
</script>
|
46
|
+
</head>
|
47
|
+
<body>
|
48
|
+
<p><textarea id="rawData"></textarea></p>
|
49
|
+
<p><input type="text" id="hash"></p>
|
50
|
+
</body>
|
51
|
+
</html>
|
52
|
+
```天気予報が変わるまでは、同じハッシュが返ります。
|
53
|
+
キャッシュをクリアしても同じ値になるので、同じJSONだと確認できます。
|