Ashok Padmanabhan
Ashok Padmanabhan

Reputation: 2120

How to embed tweets in asp.net application

I want to embed tweets in an asp.net application/page. Something akin to the wordpress feature where all one has to do is paste the url for tweet in the editor and WP automagically embeds the tweet. Or maybe some sort of shortcode like [tweet:numeric_String_here] and then this becomes a nicely formatted tweet. After much googling i have found a couple of potential solutions. One is clients side - EmbedTweet which i i just tried but does not work. I know twitter uses OAuth so this script may use their legacy api. The other solution is to work with OEmbed based on what i rad at twitter's dev section. So before I start heading a potential blind alley I'd like a little direction on what i should i look at to embed tweets with asp.net, Could be a client side solution too. I'd rather use use a pre-built solution but if i have to roll my own i can. Does Linq to Twitter or Twitterizer support embeding tweets? Or should I use JSON.net to get the tweet info via JSON?

Upvotes: 2

Views: 1332

Answers (1)

Joe Mayo
Joe Mayo

Reputation: 7513

Twitter has a statuses/oembed.json endpoint that I implemented in LINQ to Twitter. Here's an example of how you might use it:

    static void OEmbedStatusDemo(TwitterContext twitterCtx)
    {
        var embeddedStatus =
            (from tweet in twitterCtx.Status
             where tweet.Type == StatusType.Oembed &&
                   tweet.ID == "305050067973312514"
             select tweet.EmbeddedStatus)
            .SingleOrDefault();

        Console.WriteLine("Embedded Status Html: " + embeddedStatus.Html);
    }

Upvotes: 2

Related Questions