-
Notifications
You must be signed in to change notification settings - Fork 60
Error in make_query. Status code: 400 #180
Comments
I am getting the same error. In my case, it was working perfectly till yesterday. I'm getting this error from this evening. Might be a problem at Twitter's end. |
Same issue here. Python works with no problem though and same bearer. |
Works fine for me also yesterday. |
Twitter just changed its API a few days ago, if a user requests |
Thanks for the response @justinchuntingho. |
I'm having an issue on this front. I ran this code about 4-5 days ago with no issue--I was getting tweets scraped of upwards of 250,000 which was fantastic. Now I am getting this 400 error message and using page_n =100 obviously limits me to 100 tweets per page and maxing out my tweets at 100. Is there a workaround for this or is this package now limiting to that few of tweets? |
Starting from #181, you should now be able to specify |
This is the message I get with the following code: tweets4 <- get_all_tweets(query=build_query("sanctuary cities OR sanctuary city",is_retweet=FALSE,lang="en"),start_tweets="2018-01-01T00:00:00Z",end_tweets="2018-01-03T00:00:00Z", bearer_token=bearer_token, data_path = "data6/", bind_tweets = TRUE, context_annotations=FALSE, page_n=500) |
@jmwright432 How about city",is_retweet=FALSE,lang="en"),start_tweets="2018-01-01T00:00:00Z",end_tweets="2018-01-03T00:00:00Z", bearer_token=bearer_token, data_path = "data6/", bind_tweets = TRUE, context_annotations=FALSE, page_n=500, n = Inf) You needa tune the |
From what I understand about the new twitter update and this package, you should still be able to mine > 100 tweets , it will just be much slower if you want context_annotations until an update @justinchuntingho ? |
I am not @justinchuntingho (I'm the quiet Beatle). But I can answer your question @natesheehan. The update is there, now. You can install the Github version. First thing first, you can get more than 100 tweets. You can get 1000 tweets in 5s, for example. The only change is that you won't get the require(academictwitteR)
#> Loading required package: academictwitteR
start_time <- Sys.time()
x <- get_all_tweets(
query = "#ichbinhanna",
start_tweets = "2021-01-01T00:00:00Z",
end_tweets = "2021-07-01T00:00:00Z",
n = 1000
)
#> Warning: Recommended to specify a data path in order to mitigate data loss when
#> ingesting large amounts of data.
#> Warning: Tweets will not be stored as JSONs or as a .rds file and will only be
#> available in local memory if assigned to an object.
#> query: #ichbinhanna
#> Total pages queried: 1 (tweets captured this page: 500).
#> Total pages queried: 2 (tweets captured this page: 500).
#> Total tweets captured now reach 1000 : finishing collection.
end_time <- Sys.time()
end_time - start_time
#> Time difference of 4.990046 secs
nrow(x)
#> [1] 1000 Created on 2021-07-04 by the reprex package (v2.0.0) If you need those context annotations, you need to specify it explicitly in your call to require(academictwitteR)
#> Loading required package: academictwitteR
start_time <- Sys.time()
x <- get_all_tweets(
query = "#ichbinhanna",
start_tweets = "2021-01-01T00:00:00Z",
end_tweets = "2021-07-01T00:00:00Z",
n = 1000,
context_annotations = TRUE
)
#> Warning: Recommended to specify a data path in order to mitigate data loss when
#> ingesting large amounts of data.
#> Warning: Tweets will not be stored as JSONs or as a .rds file and will only be
#> available in local memory if assigned to an object.
#> page_n is limited to 100 due to the restriction imposed by Twitter API
#> query: #ichbinhanna
#> Total pages queried: 1 (tweets captured this page: 100).
#> Total pages queried: 2 (tweets captured this page: 100).
#> Total pages queried: 3 (tweets captured this page: 100).
#> Total pages queried: 4 (tweets captured this page: 100).
#> Total pages queried: 5 (tweets captured this page: 100).
#> Total pages queried: 6 (tweets captured this page: 100).
#> Total pages queried: 7 (tweets captured this page: 100).
#> Total pages queried: 8 (tweets captured this page: 100).
#> Total pages queried: 9 (tweets captured this page: 100).
#> Total pages queried: 10 (tweets captured this page: 100).
#> Total tweets captured now reach 1000 : finishing collection.
end_time <- Sys.time()
end_time - start_time
#> Time difference of 11.94927 secs
nrow(x)
#> [1] 1000 Created on 2021-07-04 by the reprex package (v2.0.0) |
Thanks @chainsawriot adding the n=Inf worked. I’m getting closer to 250k tweets now which was what I was getting a few days ago. Clearly the syntax has changed in the code. Much appreciated! |
@chainsawriot hey quiet Beatle - great answer and thanks for this tip!
Got that n tuned finely now! Many thanks @justinchuntingho for the speedy fix! |
Many thanks guys for fixing this. @justinchuntingho @chainsawriot you guys are amazing. |
Hi @chainsawriot, I still have a problem with the status code: 400. Below is my code. Can you please tell me what I did wrong? I tried to add page_n=500 but it did not work. page_n = 100 worked, but I noticed that it took longer than a few days ago when the update had not happened yet. |
Hi @helennguyen1312 , You need to update the package. It is not yet push to CRAN, but you can install the dev version as shown below.
This is is what works for me. Best, |
@shmuhammad2004 Thank you so much! I got it now. |
Hi @chainsawriot sorry to bother you. I'm still having issues in getting tweets. Then, I try to get tweets with the following command: Such a command does not work. The error is the following I tried to introduce The command works only with Thank you all in advance for your great work and support. |
@AndreaaMarche Have you installed the latest Github version? devtools::install_github("cjbarrie/academictwitteR", build_vignettes = TRUE) Can't reproduce your error. require(academictwitteR)
#> Loading required package: academictwitteR
query <- build_query( query = "blabla", is_retweet = FALSE, has_hashtags = TRUE,
remove_promoted = TRUE)
try <- get_all_tweets( query = query, file = NULL, data_path = NULL,
bind_tweets = TRUE, start_tweets = "2021-06-11T00:00:00Z",
end_tweets = "2021-07-04T23:59:59Z", verbose= FALSE, n = 2000)
nrow(try)
#> [1] 2000 Created on 2021-07-05 by the reprex package (v2.0.0) |
@chainsawriot It works if I do not specify If possible, I would like to know the maximum |
@AndreaaMarche Study |
Hi @chainsawriot! I'm having the same exact issue @AndreaaMarche had, but her solution is not working for me, as I never specified
This gives me the 400 error:
I've installed the latest dev version of the package, but like @AndreaaMarche I can't introduce Thanks so much! |
@kobihackenburg can't reproduce require(academictwitteR)
#> Loading required package: academictwitteR
hillary_tweets <- get_all_tweets(users = c("HillaryClinton"), start_tweets = "2015-04-12T00:00:00Z", end_tweets = "2016-06-06T00:00:00Z", bind_tweets = TRUE, page_n = 500, n = Inf)
#> Warning: Recommended to specify a data path in order to mitigate data loss when
#> ingesting large amounts of data.
#> Warning: Tweets will not be stored as JSONs or as a .rds file and will only be
#> available in local memory if assigned to an object.
#> query: (from:HillaryClinton)
#> Total pages queried: 1 (tweets captured this page: 496).
#> Total pages queried: 2 (tweets captured this page: 500).
#> Total pages queried: 3 (tweets captured this page: 499).
#> Total pages queried: 4 (tweets captured this page: 496).
#> Total pages queried: 5 (tweets captured this page: 486).
#> Total pages queried: 6 (tweets captured this page: 494).
#> Total pages queried: 7 (tweets captured this page: 494).
#> Total pages queried: 8 (tweets captured this page: 500).
#> Total pages queried: 9 (tweets captured this page: 491).
#> Total pages queried: 10 (tweets captured this page: 498).
#> Total pages queried: 11 (tweets captured this page: 497).
#> Total pages queried: 12 (tweets captured this page: 430).
#> This is the last page for (from:HillaryClinton) : finishing collection. Created on 2021-07-06 by the reprex package (v2.0.0) I am using 0.2.1 a.k.a. the current Github version. |
If you are supplying the arguments in the order they were defined, you need to name them, eg you need to state explicitly |
Patch v0.2.1 now on CRAN: ref. commit 49d0c7e |
I run the code below to extract tweets with hashtag #BlackLivesMatter. But, it returns an error
Error in make_query(url = endpoint_url, params = params, bearer_token = bearer_token, : something went wrong. Status code: 400
.I understand error
400
means bad request but the query is a verbatim copy from academictwitteR.Expected behavior
Return the expected tweets as queried.
Session Info:
Thanks @cjbarrie for the amazing work.
Please, kindly advised.
Best,
Shamsuddeen
The text was updated successfully, but these errors were encountered: