I'm not very good at interpreting how to build a query= with multiple operators. The below examples of attempts that are invalid for the Twitter API v2 . Can someone show me how to make a proper query with multiple operators using the Tweet Count API?
Attempts (title: 'Invalid Request',
detail: 'One or more parameters to your request was invalid.',):
https://api.twitter.com/2/tweets/counts/recent?query=#animals OR #animals
https://api.twitter.com/2/tweets/counts/recent?query=(#animals OR #animals)
Working (would like to combine these):
https://api.twitter.com/2/tweets/counts/recent?query=#animals
https://api.twitter.com/2/tweets/counts/recent?query=#animals
Figured it out. It appears Twitter v2 API requires encoded # (%23), spaces (%20), and # (%40). The below query is valid:
https://api.twitter.com/2/tweets/counts/recent?query=%23animals%20OR%20%40animals
Related
I need to extract Twitter data, specific to a country using the place_country: keyword in the search_fullarchive command.
x<-search_fullarchive("keyword", n=100,fromDate ="202003151558", toDate="202004101900",env_name="name",parse=TRUE,token = Token, place_country:"US")
After execution, I get the error:
"object 'place_country' not found."
search_fullarchive() sends requests to the premium Twitter API which uses other operators than the free API.
You have to use the place: operator in the search query instead.
Type ?search_fullarchive to see the limited documentation on this.
Or look at a few imperfect examples here:
How to define search queries in rtweet fullarchive and 30day search
Have you figure this out? If not, I had the same issue and I can help.
Your operator place_country:US should be in the keyword search argument x <- search_fullarchive(q = "place_country:US", n=100,fromDate ="202003151558", toDate="202004101900",env_name="name",parse=TRUE,token = Token)
Cheers!
I am trying to access the Time Entries object via the Kronos API v2.
The documentation says that there are two required Query Parameters: start_date and end_date.
I am able to query the endpoint including one of the parameters at a time but am not able to enter both. And, I find the documentation quite lacking.
The root of the endpoint is:
https://secure.saashr.com/ta/rest/v2/companies/{cid}/time-entries
Here are things I have tried to suffix to the above endpoint:
?start_date=2019-11-01&end_date=2019-12-01
?start_date=2019-11-01|end_date=2019-12-01
?start_date=2019-11-01 end_date=2019-12-01
?start_date=2019-11-01?end_date=2019-12-01
?start_date=2019-11-01:end_date=2019-12-01
?filter=start_date:=:2019-11-01|end_date:=:2019-12-01
I also tried including quotes around the dates.
Everything results in some 400 level error when querying the API. With most of the above suffixes, it recognizes start_date but not the end_date. In this case, the error is:
{'code': 400, 'message': 'Missing required: end_date'}]
Note, above {cid} is replaced with the company's id.
In summary, how should I include two query parameters in the Kronos API?
The first option is correct.
https://secure.saashr.com/ta/rest/v2/companies/{cid}/time-entries?start_date=2019-11-01&end_date=2019-12-01
should work just fine.
Could you provide full URL you set in request?
It seems that in V2 it was possible to set how many translations you wanted returned from the API. I am new to the service and with V3 I have not found a method or parameter that lets me get more than the one translation that the API 'assumes' that I want.
For example, searching the phrasal verb 'pick up' alone returns 'podniesc' in Polish. Searching 'pick up from the airport' returns 'odbior z lotniska', 'odbior' being the other meaning of pick up, i.e. collect. I would like to have multiple options returned without needing to add additional context.
The Dictionary function of the Translator Text API returns rich information about the word or phrase passed in:
https://learn.microsoft.com/en-us/azure/cognitive-services/translator/reference/v3-0-dictionary-lookup
Alternative translations are not part of Translator Text API v3. There's a possibility in the future to include this feature though no promises.
I am working in R with the twitteR package, which is meant to get information from Twitter through their API. After getting authentificated, I can download information about any user with the getUser function. However, I am not able to do so with usernames which are only numbers (for example, 1234). With the line getUser("1234") I get the following error message:
Error in twInterfaceObj$doAPICall(paste("users", "show", sep = "/"),
params = params, : Not Found (HTTP 404).
Is there any way to get user information when the username is made completely of numbers? The function tries to search by ID instead of screenname when it finds only numbers.
Thanks in advance!
First of all, twitteR is deprecated in favour of rtweet, so you might want to look into that.
The specific user ID you've provided is a protected account, so unless your account follows it / has access to it, you will not be able to query it anyway.
Using rtweet and some random attempts to find a valid numerical user ID, I succeeded with this:
library(rtweet)
users <- c("989", "andypiper")
usr_df <- lookup_users(users)
usr_df
rtweet also has some useful coercion functions to force the use of screenname or ID (as_screenname and as_userid respectively)
I am using R and I need to retrieve the few most recent posts from a Twitter user (#ExpressNewsPK) using twitteR api. I have created an account and have an access token, etc. I have used the following command to extract the tweets:
setup_twitter_oauth(consumerkey,consumersecret,accesstoken,accesssecret)
express_news_tweets <- searchTwitter("#ExpressNewsPK", n = 10, lang = "en" )
However, the posts that are returned aren't the most recent ones from this user. Where have I made a mistake?
I think searchTwitter would search with the search string provided (here #ExpressNewsPK). So instead of giving tweets by #ExpressNewsPK it would give tweets which are directed to #ExpressNewsPK.
To get tweets from #ExpressNewsPK, you have a function named userTimeline which would give tweets from a particular user.
So after you are done with setup_twitter_oauth, you can try
userTimeline("ExpressNewsPK")
read more about it at ?userTimeline
When you use searchTwitter(), you call the Twitter Search API. Search API only returns a sample history of the tweets.
What you really need to do is to call Twitter Streaming API. Using it you'll be able to download tweets in near real time. You can read more about the Streaming API here: https://dev.twitter.com/streaming/overview