I'm building a 'social media widget' for work's website. I'm now adding Foursquare to it and would like to use the Foursquare API to display all the checkins and tips left at our 29 locations. I don't need any user data but when I look through the Endpoint pages on the dev site and select the venue platform API, it greys out the stats endpoint. The tips endpoint is ok to use though so this isn't the issue.
Is there a way to access the number of checkins at a venue without going through authorisation? I just need the number of checkins.
Thanks, Colin
I've now successfully been able to get the data I needed. I used the /venues/
endpoint with the id of the venues that 'we' own. I then bundled these into a /multi/
endpoint request (I used an array of calls to get over the 5 request limit). My jQuery code is below (I'm on a classic ASP server and without loading other libraries can't use JSON).
var endpoint = "https://api.foursquare.com/v2/multi?requests=";
var numbers = new Array();
numbers[0] ="/venues/[VENUE ID],/venues/[VENUE ID],/venues/[VENUE ID],/venues/[VENUE ID],/venues/[VENUE ID]";
numbers[1] = "/venues/[VENUE ID],/venues/[VENUE ID],/venues/[VENUE ID],/venues/[VENUE ID],/venues/[VENUE ID]";
numbers[2] = "/venues/[VENUE ID],/venues/[VENUE ID],/venues/[VENUE ID],/venues/[VENUE ID],/venues/[VENUE ID]";
numbers[3] = "/venues/[VENUE ID],/venues/[VENUE ID],/venues/[VENUE ID],/venues/[VENUE ID],/venues/[VENUE ID]";
numbers[4] = "/venues/[VENUE ID],/venues/[VENUE ID]";
var auth_string = "&client_id=[CLIENT ID]&client_secret=[CLIENT SECRET]&v=[DATE in YYYYMMDD]";
var checkins = 0;
var tips = 0;
$.each(numbers,function(index,value) {
$.getJSON(endpoint + numbers[index] + auth_string,function(json){
$.each(json.response.responses,function(index){
checkins = checkins + json.response.responses[index].response.venue.stats.checkinsCount;
tips = tips + json.response.responses[index].response.venue.stats.tipCount;
});
$("#foursq #checkins").html("Checkins: " + checkins + "<br />");
$("#foursq #tips").html("Tips: " + tips);
});
});
This basically just loops through every venue grabs the stats for checkinsCount and tipCount and then adds them to the total. It then prints these into wherever you want to display. I've found an issue with the count though as if you don't print the values off outside of the 'getJSON' loop it becomes 0.
Hope this helps anyone else doing something similar