Skip to content

Instantly share code, notes, and snippets.

@WebRTCGame
Created October 30, 2014 12:54
Show Gist options
  • Save WebRTCGame/26e9cc41361478fca893 to your computer and use it in GitHub Desktop.
Save WebRTCGame/26e9cc41361478fca893 to your computer and use it in GitHub Desktop.
Clicky API get and display visitors cross-origin
<style>
#myTable tr {
padding: 5px;
margin: 5px;
border: 1px solid black;
}
#myTable td {
padding: 5px;
margin: 5px;
}
</style>
<table id="myTable">
<tbody></tbody>
</table>
<script>
var siteId = "100785168";
var siteKey = "a10a8e6a8882f357";
$.getJSON('http://anyorigin.com/dev/get?url=http%3A//api.clicky.com/api/stats/4%3Fsite_id%3D' + siteId + '%26sitekey%3D' + siteKey + '%26type%3Dvisitors-list%26output%3Djson&callback=?', function (data) {
for (var i = 0; i < data.contents[0].dates.length; i++) {
var items = data.contents[0].dates[i].items;
for (var j = 0; j < items.length; j++) {
$('#myTable').append('<tr><td>Visitor from: </td><td>' + items[j].geolocation + '</td><td> at </td><td>' + items[j].time_pretty + '</td></tr>');
}
}
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment