2

I am using Twitter REST Api for get my Timeline Tweets. Currently I am using following functions to get Tweets and these are working well.

https://api.twitter.com/1.1/statuses/home_timeline.json

https://api.twitter.com/1.1/statuses/user_timeline.json

Now I want to get filtered Timeline Tweets. I am using both Text search and Location filters with this Link.

https://api.twitter.com/1.1/search/tweets.json?q=[text]&geocode=[lat/lon]

I want get My Timeline Tweets but it returns global tweets.

How can I implement filters on my account?

Do I need to create custom function to fulfill my requirement?

Shoaib Ijaz
  • 5,347
  • 12
  • 56
  • 84
  • You should use twitter search api like: `https://api.twitter.com/1.1/search/tweets.json?q=from%3A[username]%20[text]&geocode=[lat/lon]` take a look at: [link](https://dev.twitter.com/rest/public/search) – Kadir Oct 20 '15 at 11:47
  • What do you mean by "Timeline Tweets"? – Terence Eden Oct 20 '15 at 11:55
  • Timeline Tweets mean Tweets of followers and following. I am fetching these tweets from above mentioned two URLS. – Shoaib Ijaz Oct 20 '15 at 12:32

2 Answers2

2

What you are asking is not possible using standard Twitter APIs.

There are two ways to achieve what you are asking:

  1. You can fetch tweet from timeline and then filter tweets from it in your application. It's the only feasible option.
  2. Other option is to use search using Twitter API and filter out tweets of the people you are following. But this is not going to be feasible option.

I think option 1 is the only thing that you can practically do.

ksg91
  • 1,279
  • 14
  • 34
0

You got it right that the user and home timelines have only very limited filtering capabilities (time restrictions by minimum time stamp and max ID). At the same time the generic search is generic by default.

To search in specific users' timelines is possible using the generic Search API' from: operator: you can limit the result set by the sender https://developer.twitter.com/en/docs/twitter-api/tweets/search/integrate/build-a-query

V1.1 https://developer.twitter.com/en/docs/twitter-api/v1/tweets/search/api-reference/get-search-tweets:

https://api.twitter.com/1.1/search/tweets.json?q=from%3A[userhandle]%20[keyword]&geocode=[lat/lon]

V2 https://developer.twitter.com/en/docs/twitter-api/tweets/search/api-reference/get-tweets-search-recent:

https://api.twitter.com/2/tweets/search/recent?query=from%3A[userhandle]%20[keyword]&geocode=[lat/lon]

The from operator works both with Twitter handle or Twitter user id.

Csaba Toth
  • 10,021
  • 5
  • 75
  • 121