2
我從這個URL如何從URL發佈JSON數據Pubnub
http://api.thingspeak.com/channels/18675/feed/last.json
如何發佈這些數據Pubnub一些JSON數據? 這裏我已經寫了一些代碼爲實時圖形,但輸入圖形是恆定的data.i想使用jQuery的功能的getJSON獲取thingspeak數據從URL
<html>
<head>
<script type="text/javascript" src="http://pubnub.github.io/eon/v/eon/0.0.10/eon.js"></script>
<link type="text/css" rel="stylesheet" href="http://pubnub.github.io/eon/v/eon/0.0.10/eon.css" />
</head>
<body>
<div id="chart"></div>
<script>
var pubnub = PUBNUB.init({
publish_key: '',
subscribe_key: ''
});
var channel = "c3-spline-history-test";
eon.chart({
history: true,
channel: 'process-memory-demo',
flow: true,
limit: 100,
debug: false,
pubnub: pubnub,
rate: 500,
debug: true,
generate: {
bindto: '#chart',
transition: {
duration: 1
},
data: {
type: 'scatter',
labels: true
}
}
});
</script>
<script type="text/javascript">
setInterval(function(){
pubnub.publish({
channel: channel,
message: [23,45,66,99,77] //replace this data with JSON data from URL
});
}, 1000);
</script>
</body>
</html>
到目前爲止您嘗試過什麼?請閱讀http://stackoverflow.com/help/how-to-ask – ericbn
通過XHR獲取JSON數據。對於每個點,發佈爲對象**'{eon:{columnHeaderName1:45.32,columnHeaderName2:77.212}} ** – PubNub