R - Twitter - create a graph of tweets by country (geographic location)
I am trying to create a graph of tweets for a specific hashtag according to geographic location. The place must be a country.
I would like to check if my code below is actually filtering tweets by country (France in this case):
tag=„NBA"
# determine place id corresponding to country coordinates
geo=GET("https://api.twitter.com/1.1/geo/search.json?query=France&granularity=country",
config(token = twitter_token))
geo <- content(geo, as = "text")
geo=fromJSON(geo)
country_id= geo$result$places$id
# use id to filter tweets by country
req=GET(sprintf("https://api.twitter.com/1.1/search/tweets.json?q=%%23%s&src=typd&count=100&id=%s",
tag, country_id),
config(token = twitter_token))
req <- content(req, as = "text")
newTweets=fromJSON(req)
Is this the way?
What I find somewhat perplexing is that according to ...
https://dev.twitter.com/rest/reference/get/search/tweets
... there is only the option to set an option geocode
, but nothing is mentioned regardingplace_id
+3
source to share
No one has answered this question yet
See similar questions:
or similar: