4

I am new to Twitter and need some tips.

I need to display tweet feed from multiple users on some webpage.

The first thing I stumbled upon is Embedded Timelines. It allows to display tweets from list of users but the gotcha is that those lists should be maintained on Twitter-side (i.e. I cannot specify @qwe and @asd only on my side and get timeline without adding those users into list on Twitter-side).

The thing is that list of users that should be included into timeline is dynamic and managing those lists through Twitter API will probably be painful. Not to mention that my website will probably generate tons of those lists and I feel that I will violate some api quotas sooner or later.

So, my question is - am I stuck with using Embedded Timelines that refer some user list on Twitter-side and managing those lists through, say Twitter REST api, or there is a simplier way to do what I want?

Eugene Loy
  • 12,224
  • 8
  • 53
  • 79

1 Answers1

7

It's pretty simple to display tweets for multiple users.

Links to start with

  • This post explains some of the search queries you can make
  • This post is a simple library to make requests to the twitter API that 'just works'

Your Query

Okay, so you want multiple users. The endpoint you're looking at using is the search/tweets one: https://api.twitter.com/1.1/search/tweets.json.

The query string uses :from and you can interpolate multiple froms with AND/OR.

An example query for the GET request:

?q=from:user1+OR+from:user2

Read more about the search API queries here.

Your "over-the-quote" issue

This is something you're going to need to figure out yourself - depending on the number of requests you expect to make, and the twitter imposed limits, maybe some sort of caching or saving information when you hit your limit, and only pull back from the cache whilst you're hitting your limit..

Community
  • 1
  • 1
Jimbo
  • 25,790
  • 15
  • 86
  • 131
  • Thanks, that seems more or less what I want, however getting those tweets is only half of a story, since now I have to render them. Do you have any tips on how to do this as easy as possible, preferable on client-side (server-side is C#)? – Eugene Loy Jul 10 '13 at 11:52
  • Hmm, tips.. this depends on the data you get back. Your first step is to use the query documentation to limit the results as much as you can on twitter's side. Then once you get your data, you're going to have to figure out the most optimum way to loop your data and pull out what you require. For example, in PHP an `array_walk()` is better than `foreach()` for large datasets because of *Copy-On-Write* - might want to look into this for your client side language of choice (why are you doing this client side anyway, why not let your server handle the looping?) – Jimbo Jul 10 '13 at 12:26