Hi,
I have the Sandbox tier and I am using rtweet in R. The code seems to be successful for both the full archive and 30 days search (have pasted below) but I get errors saying that I am not authorized to access this resource. I made sure I specified the code according to what is available for Sandbox but I still get those errors. Any help would be appreciated!!
testfull <- search_fullarchive(
q = “#blm OR #blacklivesmatter OR diverse OR diversity OR racism OR George Floyd OR ‘black lives matter’ OR racial OR race OR justice”,
n = 100,
fromDate = 202005250000,
toDate = 202006252359,
env_name = “proresponsefull”,
safedir = NULL,
parse = TRUE,
token = NULL
)
tweets/search/fullarchive/proresponsefull ***list(message = “Forbidden: Authentication succeeded but account is not authorized to access this resource.”, sent = “2020-07-06T06:33:42+00:00”, transactionId = “004c3eb80006937e”)
Also for the 30-days:
test30 <- search_30day(
q = “#blm OR #blacklivesmatter OR diverse OR diversity OR racism OR George Floyd OR ‘black lives matter’ OR racial OR race OR justice”,
n = 100,
fromDate = 202005250000,
toDate = 202006252359,
env_name = “proresponse30”,
safedir = NULL,
parse = TRUE,
token = NULL
)
tweets/search/30day/proresponse30 ***list(message = “Forbidden: Authentication succeeded but account is not authorized to access this resource.”, sent = “2020-07-06T14:15:49+00:00”, transactionId = “009256e300986f8d”)
Make sure that the app keys you’re using belong to the app that is configured on the environment https://developer.twitter.com/en/account/environments
Also, it may be worth using https://blog.twitter.com/developer/en_us/topics/tips/2020/running-the-python-package-for-search-tweets-in-r.html this way to access premium endpoints as rtweet still has some bugs (it’s very easy to use up all your calls because it hard codes and limits results to 100 per page for paid premium)
Thank you for your response! Everything is correct with the app keys and environment.
I actually was trying to follow that post and use Python in R but ran into an issue with authenticating. Everything up to this point worked. I changed the account type. I put the env name before the “.json” in the link, and pasted the other info in as well.
search_tweets_api:
account_type: sandbox
endpoint: https://api.twitter.com/1.1/tweets/search/30day/changed to my env name.json
consumer_key: xxxxxxxxxxxxxxxxxxx
consumer_secret: xxxxxxxxxxxxxxxxxxx
This is the error I get:
Error: invalid syntax (, line 1)
I am still very much new to coding and can’t seem to find any answers (through googling) to fix this issue/authenticate so I can move to the next step on the post.