Question

I'm trying to pull tweets using the twitteR package, but I'm having an issue getting them through the searchTwitter function when I specify a geocode the way they have it in their docs. Please see code below:

    #Oauth code (successful authentication)

    keyword = "the"
    statuses = searchTwitter(keyword, n=100, lang="en",sinceID = NULL, geocode="39.312957, -76.618119, 10km",retryOnRateLimit=10)

Code works perfectly when I leave out geocode="39.312957, -76.618119, 10km",, but when I include it, I get the following:

    Warning message:
    In doRppAPICall("search/tweets", n, params = params, retryOnRateLimit = retryOnRateLimit,  :
    100 tweets were requested but the API can only return 0

I thought maybe my formatting was wrong but based on the twitteR CRAN page the string is in the right format (I also tried switching between km and mi).

Has anyone else experienced this or know a better way to search for a specific geocode? Would they have deprecated the geocode functionality?

I'm looking for tweets from Baltimore so if there is a better way to do so, I'm all ears. (By the way, I want to avoid trying to pull all tweets and then filter myself because I think I will hit the data limit fairly quickly and miss out on what I'm looking for)

Thanks!

Was it helpful?

Solution

I believe you need to remove the spaces in the geocode parameter:

statuses = searchTwitter(keyword, n=100, lang="en",sinceID = NULL, geocode="39.312957,-76.618119,10km",retryOnRateLimit=10)

FWIW You can use the Twitter desktop client "Develop" console to test out URLs before committing them into scripts.

OTHER TIPS

Had the same issue. Your parameters are in the correct order, but you must avoid any whitespace within the geocode. Also, 10km might be too little a radius for the accuracy of the coordinates given, might want to try with 12mi.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top