我正在尝试将简单的 import.io 与 JavaScript(示例网站)结合使用,但脚本不起作用。你能帮助我吗?
<!DOCTYPE html> <html> <head> <title>Import•io
Example</title> <script
src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<!-- 1. Include the client library --> <script
src="https://cdn.import.io/js/2.0.0/importio.js"></script>
<!-- 2. Configure the library --> <script type="text/javascript">
importio.init({
"auth": {
"userGuid": "XXX",
"apiKey": "XXX"
},
"host": "import.io"
});
// Data and done callbacks
var dataCallback = function(data) {
console.log("Data received", data);
for (var i = 0; i < data.length; i++) {
var d = data[i]; for (var k in d.data) {
document.write("<i>" + k + "</i>: " + d.data[k] + "<br />"); } document.write("<hr>"); }
}
var doneCallback = function(data) {
console.log("Done, all data:", data);
document.write("<b>Done</b><hr>");
}
// 3. Do the query (when the function is called)
var doQuery = function() {
// Query for tile Magic Api
importio.query({
"connectorGuids": [
"a362c175-e265-4f96-867c-5610686bbb21"
],
"input": {
"webpage/url": "http://www.davy.ie/markets-and-share-prices/iseq"
}
}, { "data": dataCallback, "done": doneCallback });
} </script> <body>
<button onclick="doQuery()">Query</button> </body> </html>