Embed multiple tweets on one page via individual ids


#1

I am trying to figure out a way with twitter’s new guidelines that will allow me to embed specific tweets from different users dynamically into a webpage. I have looked at Twitter’s oEmbed endpoint and it seems like what I need, however I am not sure how to accomplish this via one ajax call.

I obviously do not want to make tons of calls to the Twitter server and max out, so is there a way to run a loop inside a ajax call to try different tweet ids without hitting the server multiple times?

Or is there another method I am not familiar with that someone could suggest?

I hope this is clear enough of a question, thanks for taking the time to read.

cheers

$(document).ready(function(){ 
var output = $("#output");
var ids = [ php code to build an array of IDs];

for(i=0; i<ids.length; i++){
   $.ajax({
 url: 'https://api.twitter.com/1/statuses/oembed.json?id=' + ids[i] + '&align=center&callback=?',
 dataType: 'json',
 success: function(data) {
  $(data.html).appendTo(output);
    }
      });
}
});

#2

There are no bulk status methods unfortunately – you can only obtain individual tweets with one API call at a time. Instead of leveraging the oembed endpoint client-side, it would be wiser to obtain that response server-side and cache it long-term, then use it for rendering.


#3

Thank you for your response