Peter Hoffmann
Peter Hoffmann

Reputation: 58634

Format tweet on the client side with javascript?

To document some recent events I saved all tweets including a special hashtag. Now I have about 50.000 tweets which I want to publish. To save bandwidth and server load I want just want to send the raw tweet text to the client and then render it with javascript (linking hashtags, useranames and urls).

Is there already javascript library which is able to parse and create a html representation from a raw tweet?

Upvotes: 2

Views: 1031

Answers (2)

Matt Vukas
Matt Vukas

Reputation: 3295

Have you considered using the Twitter oembed API? It basically lets you request the "official" embedded tweet HTML programmatically using an anonymous API (no authentication required). This would at least make it easy to meet the display requirements without reinventing the wheel. You can even do this client side, depending on your use case.

I'm grappling with this same issue, so let us know what you try and how it works for your project.

Upvotes: 0

Inactivist
Inactivist

Reputation: 10457

twitterlib.render() looks like a good start... assuming you have parsed JSON tweet data:

<script src="twitterlib.js"></script>

<script>
    var parsed_tweet_data = getTweetData(...); // get a Tweet JS object...
    var html = twitterlib.render(parsed_tweet_data);
    // Do something with the rendered html now...
</script>

Here's a twitterlib walkthrough on SlideShare.net (slide 17 has a demo.)

Upvotes: 1

Related Questions