Working with a API and print the result 12-15-2017, 08:24 PM
#1
I'm developing an app and this code is the first part but i got stuck in code:
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:
Anyone with enough knowledge to put it to work?
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?





![[+]](https://sinister.li/images/modern/collapse_collapsed.png)