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
I don’t know what goes wrong. I get an error with the connection when I call the function:
Error in function (type, msg, asError = TRUE) :
SSL certificate problem, verify that the CA cert is OK. Details:
error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed
Ok. It appears to be a problem with RCurl package over Windows. I patched the function with this lines:
download.file(url=”http://curl.haxx.se/ca/cacert.pem”, destfile=”cacert.pem”)
u<-getURL(w, cainfo = "cacert.pem")
One warning: it seems that there are geographic limitations to the API call. I couldn't manage to retrieve venues from a european small city.
Can you please describe your patch more detailed? I’ve got the same error as you mentioned. Thank you
I {{leave|drop|write} a comment|drop a comment|leave a response} whenever I appreciate a article on a {site|blog|site|website} or I have something to contribute to the conversation. Usually it’s a result of the fire communicated in the article I browsed. And after this post educational piece. I {was moved|was actually excited} enough to {drop|{leave|drop|create}|post} a {thought|{comment|commenta response}} 🙂 I do have {some questions|a couple of questions|2 questions} for you {if you don’t mind|if it’s okay}. Could it be just me or {do|does it look like} a few of the comments look as if they are left by brain dead visitors? 😛 And, if you are writing on other places, I’d like to follow {you|everything new you have to post}. Could you list all of all your community pages like your twitter feed, Facebook page or linkedin profile?
Hi there all, here every person is sharing these kinds of
know-how, therefore it’s pleasant to read this blog,
and I used to visit this blog daily.
Greetings! Very useful advice within this article! It is
the little changes that produce the most important
changes. Thanks a lot for sharing!
can u please your patch detailly, even me getting same error