![]() |
|
Working with a API and print the result - Printable Version +- Sinisterly (https://sinister.li) +-- Forum: Coding (https://sinister.li/Forum-Coding) +--- Forum: Coding (https://sinister.li/Forum-Coding--71) +--- Thread: Working with a API and print the result (/Thread-Working-with-a-API-and-print-the-result) |
Working with a API and print the result - hacxx - 12-15-2017 I'm developing an app and this code is the first part but i got stuck in code: Code: Object: <a id='bot'></a>
<script>
var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
var myObj = JSON.parse(this.responseText);
document.getElementById("bot").innerHTML = myObj.matches;
}
};
xmlhttp.open("GET", "https://api.shodan.io/shodan/host/search?key=CevVNIYrV6gUzMoxiMhcaO3JIJOmpCY1&facets=&query=xampp", true);
xmlhttp.send();
</script>The response i get by trying to retrieve myObj.matches.ip_str is undefined The response i get by trying to retrieve myObj.matches is [object Object] ========================================================= The sample response from the docs will be: Code: {
"matches": [
{
"os": null,
"timestamp": "2014-01-15T05:49:56.283713",
"isp": "Vivacom",
"asn": "AS8866",
"hostnames": [ ],
"location": {
"city": null,
"region_code": null,
"area_code": null,
"longitude": 25,
"country_code3": "BGR",
"country_name": "Bulgaria",
"postal_code": null,
"dma_code": null,
"country_code": "BG",
"latitude": 43
},
"ip": 3579573318,
"domains": [ ],
"org": "Vivacom",
"data": "@PJL INFO STATUS CODE=35078 DISPLAY="Power Saver" ONLINE=TRUE ",
"port": 9100,
"ip_str": "213.91.244.70"
},
...
],
"facets": {
"org": [
{
"count": 286,
"value": "Korea Telecom"
},
{
"count": 229,
"value": "Comcast Cable"
},
{
"count": 113,
"value": "Taiwan Academic Network"
},
{
"count": 107,
"value": "University of Minnesota"
},
{
"count": 104,
"value": "Tiawan Academic Network (TANet) Information Center"
}
]
},
"total": 12039
}Anyone with enough knowledge to put it to work? RE: Working with a API and print the result - innocent21 - 12-17-2017 Ask your question on Stack Overflow RE: Working with a API and print the result - hacxx - 12-18-2017 No need to, just googling it and browsing. Normally it's the first result. |