Shopping Cart (0)

Adding a Tweet Box to your site

1 Posted April 20, 2012 by Rockstar Frog Categories: Code Snippets

Both Windows and Mac are integrating social media platforms more and more into their systems – creating a new Tweet is just a click or two away. You can do this on your own website too by integrating with the Twitter Development platform. Today we’re going to cover how to add a “Tweet Box” to any page on your site.

This is what we’re going to create (as seen at the end of the checkout process on eFrogThemes.com)

It’s actually a very simple process. Let’s get started:

Firstly, you’re going to want to create a Twitter application. You can do this here: https://dev.twitter.com/. Once you’ve created your app, you’ll be presented with a screen that details some key information about your application.

What you need to note down for the purposes of your Tweet Box, is just the ‘Consumer Key’.

Secondly we’re going to add the required code to 2 places in your site. Firstly, in the header you’ll want to include the Twitter Javascript library.

<script src="http://platform.twitter.com/anywhere.js?id=[YOUR KEY GOES HERE]&amp;v=1"></script>

Enter your unique Consumer Key into the above snippet and add that before the close of your head tag.

Thirdly and lastly, wherever you want the actual Tweet Box to display, you’ll add the following:

<div id="tbox"></div>
<script type="text/javascript">
 
  twttr.anywhere(function (t) {
 
    t("#tbox").tweetBox({
      height: 100,
      width: 574,
      label: 'Tell your friends about your purchase!',
      defaultContent: "I just bought a theme from @efrogthemes :)"
    });
 
  });
 
</script>

And that’s that. Right out the box your Tweet Box will work perfectly.

Optionally, you might want to edit the styling of your Tweet Box – perhaps changing the color of the textarea, or adjusting the font and size of the heading. To do this, we’re going to add a style tag to the label. The final product would look as follows:

<div id="tbox"></div>
<script type="text/javascript">
 
  twttr.anywhere(function (t) {
 
    t("#tbox").tweetBox({
      height: 100,
      width: 574,
      label: '<style>#tweet-box {background:#d5d5c3;font: 12px Verdana;resize:none;}#tweet-box-header label {font: 14px Verdana;font-weight:bold;}</style>Tell your friends about your purchase!',
      defaultContent: "I just bought a theme from @efrogthemes :)"
    });
 
  });
 
</script>

As the Javascript creates that Tweet Box then, the styling you’ve provided will be applied.

Hope you have fun inserting this Tweet Box into your own site. Let us know how you manage!

Comments

20/04/2012 1:56 pm
Guru Frog

I love nothing more than a great actionable blog post.

Thanks Rockstar!

Reply

Leave a Comment

(required)

(required, not shown)

TimThumb not displaying images? Let’s fix that!

If you've noticed that a number of images aren't displaying correctly ... Read more

George has something new to show you

Hello tadpoles! We're as happy and excited as a dog with two tails, to tell you about the latest theme from the team around the pond. It's called Cohesion, and we like to think of it as "a socially-engaged business theme". Read more

Colour palette basics – Analogous and Monochromatic Colour Schemes

Some people may have a natural knack for knowing and understanding wha... Read more

Valentines Giveaway: Win a copy of our new gorgeous theme – Occasions

Love is in the air, and lucky for you frogs aren't immune to Cupid's m... Read more

Adding a Tweet Box to your site

Both Windows and Mac are integrating social media platforms more and m... Read more

eFrog News Categories

Browse our themes