(This article was first published on NERD PROJECT » R project posts, and kindly contributed to R-bloggers)
I came up with the following function to tap into the FourSquare trending venues API:
library("RCurl", "RJSONIO") foursquare<-function(x,y,z){ w<-paste("https://api.foursquare.com/v2/venues/trending?ll=",x,"&radius=2000&oauth_token=",y,"&v=",z,sep="") u<-getURL(w) test<-fromJSON(u) locationname="" lat="" long="" zip="" herenowcount="" likes="" for(n in 1:length(test$response$venues)) { locationname[n] = test$response$venues[[n]]$name lat[n] = test$response$venues[[n]]$location$lat long[n] = test$response$venues[[n]]$location$lng zip[n] = test$response$venues[[n]]$location$postalCode herenowcount[n]<-test$response$venues[[n]]$hereNow$count likes[n]<-test$response$venues[[n]]$likes$count xb<-as.data.frame(cbind(locationname, lat, long, zip, herenowcount, likes)) } xb$pulled=date() return(xb) }
where x=”lat,long”, y=oAuth_token, and z=date. You can find out your oAuth_token by signing into FourSquare and going to https://developer.foursquare.com/docs/venues/trending, click on the “try it out” button, then copy and the code that would be where the deleted box is.
an example:
philly<-foursquare("39.9572,-75.1691","XXXXDSAFAEWRFAEFRAAFDASDFASFD","20130304")
or you can scrape by running in a repeat function.
QED
To leave a comment for the author, please follow the link and comment on his blog: NERD PROJECT » R project posts.
R-bloggers.com offers daily e-mail updates about R news and tutorials on topics such as: visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series,ecdf, trading) and more...

Zero Inflated Models and Generalized Linear Mixed Models with R.
Zuur, Saveliev, Ieno (2012).