我是新來Xively。現在我試圖從我得到的提要中訪問數據點歷史記錄。 從這個文檔:http://xively.github.io/xively-js/docs/看來,我可以使用的方法xively.datapoint.history(feedID,datastreamID,選擇{},回調(數據)),但我不知道如何使用它。如何訪問Xively數據點的歷史與JavaScript?
我知道參數feedID,datastreamID,但我不確定選項... 來自Xively網站https://xively.com/dev/docs/api/quick_reference/historical_data/,我想我應該把開始和結束參數。我使用飼料ID:40053和數據流ID:airpressure。你可以在這裏嘗試輸入飼料ID,以獲得更多的信息:http://xively.github.io/xively-js/demo/
我嘗試下面的代碼,但它不工作。我是不是做錯了什麼,或者數據點歷史本身受到限制,不能被訪問?
// Make sure the document is ready to be handled
$(document).ready(function($) {
// Set the Xively API key (https://xively.com/users/YOUR_USERNAME/keys)
xively.setKey("yWYxyi3HpdqFCBtKHueTvOGoGROSAKxGRFAyQWk5d3JNdz0g" );
// Replace with your own values
var feedID = 40053;
var datastreamID = "airpressure"; // Datastream ID
// Get datastream data from Xively
xively.datapoint.history(feedID, datastreamID,
{
start:"2013-09-10T00:00:00.703576Z",
end:"2013-10-10T00:00:00.703576Z"
},
function(data){
//data.forEach(function(datapoints){document.write(JSON.stringify(datapoints["value"], null, 4));});
document.write(JSON.stringify(data, null, 4));
});
});