Showing posts with label Twitter. Show all posts
Showing posts with label Twitter. Show all posts

Thursday, 21 March 2013

How to Get RSS Feeds for Twitter

Twitter is permanently retiring the Twitter API v1.0 sometime later this month and, to the end user, what it means is that all the existing Atom and RSS feeds of Twitter will stop working once the old API is turned off. With API v1.1, Twitter has completely switched from XML to JSON format and the other big change is that all requests to the Twitter API must now be authenticated with OAuth.
In simple English, you can no longer subscribe to any of the Twitter streams – be it search results, timelines of users, their favorites or even Twitter Lists – in your RSS Reader.
That said, there is any easy workaround.
Twitter RSS Feed

Twitter RSS Feeds – Demo

What we really need is some sort of a parsing program sitting between Twitter and our RSS Reader. The parser would fetch updates from Twitter at regular intervals and convert them from JSON to RSS which we can then subscribe in our favorite RSS Reader.
This can be easily accomplished with a simple Google Script but before getting your hands dirty, try any of the following RSS feeds. These feeds use the new Twitter API v1.1 and are served from the Google cloud.

How to Create RSS Feeds for Twitter

Step 1: Setup a Dummy Twitter App

Since the Twitter API now requires authentication for all requests, we will have to create a new Twitter App that our Google Script will use to communicate with the Twitter API.
  • Go to dev.twitter.com, sign-in with your Twitter account and create a Twitter app. Give your app any name, description, website (any URL) and put https://spreadsheets.google.com/macros/ in the callback URL field. Click Submit.
  • Once the Twitter app has been created, make a note of your Consumer Key and Consumer Secret Key.

Step 2: Configure your Google Script

  • Go to script.google.com and choose File->Make a Copy to copy that script into your Google Drive. Put the Twitter Consumer key and Secret in line # 24 and 26.
  • Go to File -> Manage Version and choose Save new version.
  • Go to Publish -> Deploy as Web App and choose Anyone, even anonymous under Who has Access. Click the Deploy button.

Step 3: Deploy the Twitter RSS Feed generator

  • Now that you have deployed the Google script, go to Run -> Start and grant the necessary permissions.
  • Choose Run -> Start again and the script will require access to Twitter. Grant access and you’ll get an email with links to some sample RSS feeds for Twitter.
That’s it. You can now generate custom RSS feeds for any Twitter Timeline, List or Search Results by simply change the value of “q” parameter in the feed’s URL. As always, you are free to use, modify and distribute the source code with attribution.

Thursday, 14 March 2013

How to Load Social Widgets Conditionally to Improve your Site’s Performance

Social Sharing is now tightly integrated into all mobile OS platforms. That means if someone is viewing a web page on an Android phone, or inside the mobile Safari browser of an iPhone, they can share that web page on Twitter and Facebook using the system-wide sharing menu without having to rely on bookmarklets or those tiny social sharing widgets.
Facebook, Twitter Integration with iOS
These “tweet” and “like” buttons add several extra kilobytes to your web pages and if mobile users are less likely to use them, you may as well consider removing the social buttons completely when your website is accessed from a mobile phone. This reduces clutter and also improves the page speed score which is now a factor in Google search rankings.

Remove the Social Buttons on Mobile Devices

If you are sort-of convinced that social sharing widgets are less useful on your mobile site, here’s what you can do to prevent them from loading on the small screen. Remember, we aren’t just hiding the buttons but removing them completely so the associated JavaScript and CSS files won’t download on the user’s mobile device.
For a quick demo, open social-widgets.html in your desktop browser and then on a mobile device. The desktop view will load the social widgets but not the mobile device.

How to Load Social Widgets Conditionally

The technique is simple. We calculate the width of the user’s screen /browser and if the width exceeds a particular value (say 480 pixels), we load the associated social widgets.
To implement conditional loading on your blog /website, first add all the necessary social widgets to your blog using the usual procedure. For instance, you can visit facebook.com to generate code for the Like button while dev.twitter.com will provides codes the Tweet and Follow widgets of Twitter.
Remove the JavaScript from these generated codes – everything that’s between the <script> tags – and add everything else to your website template. Then copy-paste the following snippet before the closing </body> tag of your website template.
  1. <script type="text/javascript">
  2. (function(doc, script, minimum) {
  3.  
  4. // Calculate the width of the user's screen
  5. var browserWidth = window.innerWidth
  6. || doc.documentElement.clientWidth
  7. || doc.body.clientWidth;
  8.  
  9. // Load JavaScript only if the site is being viewed on a wide (non-mobile) screen
  10. if (browserWidth > minimum) {
  11.  
  12. var js, frag = doc.createDocumentFragment(),
  13. // Credit : Stoyan Stefanov of phpied.com
  14. js_queue = function(url, id) {
  15. if ( ! doc.getElementById(id) ) {
  16. js = doc.createElement(script);
  17. js.src = url; js.id = id;
  18. frag.appendChild(js);
  19. }
  20. };
  21. // These are the most common social widgets, remove the ones you don't need
  22. js_queue ("https://apis.google.com/js/plusone.js", "googleplus-js");
  23. js_queue ("//platform.twitter.com/widgets.js", "twitter-wjs");
  24. js_queue ("//connect.facebook.net/en_US/all.js#xfbml=1","facebook-jssdk");
  25. js_queue ("//platform.linkedin.com/in.js", "linkedin-js");
  26. js_queue ("//assets.pinterest.com/js/pinit.js", "pinterest-js");
  27.  
  28. var fjs = doc.getElementsByTagName(script)[0];
  29. fjs.parentNode.insertBefore(frag, fjs);
  30. }
  31.  
  32. // Set the minimum width here (default is 480 pixels)
  33. } ( document, 'script', 480 ) );
  34.  
  35. </script>
The above JavaScript code asynchronously loads all the popular social widgets – Twitter, Facebook, LinkedIn, Google+ and Pinterest – but you may remove the js_queue calls for widgets that you do not plan to use on your website. Save the changes and you are done.
I have implemented a variation of the above code on my site as well. There’s a Facebook Like box in the right sidebar but it won’t load if you open this site on a mobile device.

Tuesday, 12 March 2013

How to Send Out of Office Replies in Twitter

Twitter, for many, has become a preferred medium of communication in recent years. Your email message may never get read or, in the worst case, may get caught in the Spam folder but tweets are less likely to suffer from such issues.
When you are travelling or take a “disconnected” vacation, with limited or no access to the Internet, you create an “out of office” reply in your email program to let people know that you won’t be able to respond to them right away. How about doing something similar for people who are trying to reach you through Twitter?
Twitter Auto-Reply

What will the Twitter Auto-Responder do

Unlike your email program, Twitter offers no easy way for you to setup out of office auto-replies but we can easily and quickly add such a feature to our Twitter account(s) with the help of a simple Google Script.
You specify the start date and the end date when the auto-responder should be active and any tweets sent to you during this period will automatically get a reply from your Twitter account saying you are out of office. The replies are sent once so if a person sends you two or more tweets during your vacation period, they will get only one out-of-office auto-reply.

How to Setup Out of Office Replies in Twitter

Step A: Setup a Twitter App

  1. Go to dev.twitter.com and sign-in with your existing Twitter account. Create a new Twitter app , add a description, website (any URL) and callback URL (https://spreadsheets.google.com/macros/).
  2. Once the Twitter app has been created, click the Settings tab and set Read and Write as the Application Type. Click Update to save your changes.
  3. Switch to the OAuth tool tab and make note of the Consumer Key and Consumer Secret.

Step B: Setup the Auto-responder Script

  1. Open script.google.com and choose File -> Make a copy to duplicate the auto-responder script into your Google Drive.
  2. Enter the start and end dates of your vacation, the Twitter app keys (from the previous step), and your Twitter handle.
  3. Go to Run -> Start to initialize the auto-responder. Say Yes if the script requires you to authorize access to certain Google Script services.
  4. Choose Run -> Start and it will show an “Authorization Required” dialog. Allow the script to access your Twitter account and you are done.
The script will invoke itself on the start date specified by you and will respond to all incoming tweets until the end date. It will then uninstall itself automatically. As always, you are free to use, modify and distribute the source code with attribution.
When you are taking another vacation, just open the auto-responder script already present in your Google Drive, change the Start and End dates and choose Run->Start to setup the autoresponder again.

Saturday, 9 March 2013

How to Write a Twitter Bot in 5 Minutes

Meet @DearAssistant, a Twitter bot that is like a mini version of Siri. You can tweet your questions in plan English and the bot will reply with an answer.
The Twitter bot is internally using Wolfram Alpha so there’s a whole range of questions that it can answer. Here are some questions that people have asked @DearAssistant so far:
  • How many calories are in Diet Coke? (link)
  • When was Mahatama Gandhi born? (link)
  • What is the distance between city A and city B (link)
  • Who directed the film M (link)
  • What is the price of Kindle Paperwhite.
Twitter Bot
You can also ask the bot for word meanings, weather conditions, language translation, to convert between time zones, date calculations (how many days until Christmas) and more.

Writing a Twitter Bot – The Basic Ingredients

Writing a Twitter bot is surprisingly simple and you can get one up and running in 5 minutes. It helps if you know little bit of coding (simple JavaScript) but that’s certainly not a requirement for writing a basic Twitter bot.
A bot is essentially a program that is always running in the background and whenever it encounters a command (tweets in this), it processes it (based on the text of the tweeet) and sends a reply to the tweeter in another tweet.
Earlier, you would need a web server to run the bot while the bot itself would be written in languages like PHP, Perl or Python. That’s complicated so we will use Google Scripts to write the Twitter bot and host it on our Google Drive.

How to Write a Twitter Bot – Step by Step

Step A: Setup a Twitter App

  1. Create a new account at Twitter that will become the bot. Then go to dev.twitter.com, sign-in with your new Twitter account and create a Twitter app. Give your app a name, description, website (any URL) and callback URL (https://spreadsheets.google.com/macros/). Agree to the terms, fill in the CAPTCHA and submit the form to create your first Twitter application.
  2. Once the Twitter app has been created, click the Settings tab and choose Read and Write under Application Type. This is important since we want the bot to read tweets as well as post tweets. Click the Update button to save your changes.
  3. Switch to the OAuth tool tab and make note of the Consumer Key and Consumer Secret. We will need these later in our Google Apps Script.

Step B: Create a Wolfram Alpha App

  1. While the Twitter app will monitor and respond to tweets, the Wolfram App will be used to determine answers that users will be posing to your Twitter bot.
  2. Go to developer.wolfram.com, create an account and then choose “Get an App ID” to create your new app.
  3. We will need this App ID in the Google Script. Remember that your free Wolfram Alpha App can only be used for a non-commercial purpose.

Step C: Host the Twitter bot on Google Drive

  1. While you are signed-in to your Gmail account, go to script.google.com and then choose File -> Make a copy to duplicate the Twitter bot into your Google Drive.
  2. Edit the values of TWITTER_CONSUMER_KEY, TWITTER_CONSUMER_SECRET, TWITTER_HANDLE (your new Twitter account) and WOLFRAM_API_ID – you know them all from the previous steps.
  3. Go to Run -> Start to initialize the Twitter bot. Say yes if the script requires you to authorize access to certain Google Script services.
  4. Go to Run -> Start to actually run the Twitter bot. It will show an “Authorization Required” dialog and will redirect you to Twitter where you can grant the script access to your Twitter account.
That’s it. Close Google Scripts and your Twitter bot is now up and running, ready to take commands. As always, you are free to use, modify and distribute the source code with attribution.

Saturday, 16 February 2013

Want to Know the Sleeping Time of your Friends or Celebrities

sleeping time

When do they sleep?

Actors, singers, journalists, sportsmen, musicians, writers, politicians, bloggers and your friends – they are all active on Twitter now. The only time when they are not posting messages on Twitter is probably when they are sleeping.
Introducing Sleeping Time – a mashup that will help to determine the approximate sleeping cycle of any Twitter user with a click.
Here are 1-page sleeping reports of Tech, Bollywood and my friends in India.
The algorithm uses the timestamp of the last 500 or so updates of a Twitter user to calculate his or her sleeping time. Consider this app in the early pre-alpha stages so please let me know if you encounter any bugs or if your sleeping report is way off the actual pattern.

Monday, 4 February 2013

Write longer tweets on twitter- Introducing Tall Tweets v2.0

There are situations when you need more than 140 characters to express yourself but Twitter won’t allow you post tweets that exceed the limit.
Some apps – like TwitLonger – let you bypass that 140-character limit by posting your message to another page and then tweeting the hyperlink to that page. The downside to this approach is that Twitter users will have to leave the Twitter website to read your full tweet.
If you are looking for an alternative, check out the latest version of Tall Tweets. This web app also allows you to publish longer tweets on Twitter but takes a slightly different approach as shown in this video demo.

What is Tall Tweets?

Tall Tweets will slice your tweet into multiple smaller tweets of 140 characters or less, and publishes them all to Twitter in a sequence. The tweets are numbered and are sent in a reverse arrangement such that they can be read from top-to-down inside any Twitter client.
Alternatively, you may choose to publish your long tweet as an image and in that case, the entire text gets published in a single tweet. The image tweets are rendered in the Roboto font (originally design by Google for Android) and thus the text in the images should be readable even on mobile screens.
The main advantage with Tall Tweets is that your Twitter followers can read your entire tweet inside their favorite Twitter client. This is also true for image tweets since most Twitter apps (and the Twitter.com website) offer inline image previews.
To get started, sign-in with your Twitter account, compose a tweet and hit publish. If there are hyperlinks in your tweet, they’ll be shortened using bit.ly. The app uses OAuth and therefore you won’t have to share your account credentials anywhere.
Tall Tweets
Send tweets as images and bypass the 140-character limitation of Twitter

Monday, 26 November 2012

Geotag your Tweets with any Random Location

On Twitter, if you do not wish to reveal your geographic location in your tweets, you can either completely disable the location feature from Twitter settings or you can can attach some random (read, fake) location to your tweet.
For instance, here’s a recent tweet that specific my location as the White House in Washington DC though it was written from a place that is at least 8000 miles away.
Tweet Location
Fake your geographic location on Twitter

Attach any Location to your Tweets

Now most Twitter mobile clients won’t let you attach random locations to your tweets but there’s a web-based app called PleaseDontStalkMe.com that may come handy here. Here you can pick any location on a Google Map – either drag the marker or use the search box to reach an exact address – and tweet.
Since the Twitter website no longer displays the app name that was used to send that tweet, your followers on Twitter are less likely to know that you faked your location in the tweet. Do remember to limit the length of your tweet to 140 characters else the tweet would fail but without offering an explanation.
You can geotag your tweets from the Twitter.com website as well (click the Location icon near the tweet button) but in that case, you can only attach a city-level location to the tweet and not an exact location.

Sunday, 26 August 2012

An Alternate Way to Write Long Tweets on Twitter


Want to write tweets longer than 140 characters? If you can convert your text into a 317×317 image, people can read your image-based message inside Twitter itself.
If you are to ever write a tweet that’s longer than 140 characters, you have a couple of options. You can either split the message into multiple tweets or you can use a service like post.ly that not only lets you compose essay-style messages but you may also attach documents, pictures and other files to your tweets.
I wish to share one more idea here.
Twitter has recently rolled out the picture uploads feature to all accounts worldwide. What that means is you can include an image with your tweet and your followers, or anyone else who sees that tweet, can view the content of that picture inline without having to leave the Twitter website.
The idea is that if you can convert your “long text” into a 317×317 image, people can read your message inside Twitter itself like in the following screenshot. And this works on mobile phones too.
Almost any photo editing tool – even Paint – can be used to create a text based images but remember to use the PNG or GIF image formats while saving these images.

Sunday, 29 July 2012

Use Your Twitter in Your Office Hours


Many Companies have thought that Social Media like Facebook, Twitter, Orkut etc. are time wastage and they ban these sites in their office hours.
                    If you work in companies having these policies then you have to do- Install a Twitter mobile application on your cell phone and do not use your office computer for tweeting or you can use tools like Posterous or Nutshell that allow you to send and recive tweets through regular office email. Here is another option if twitter.com is blocked by your office, you use your twitter account by third party sites like Brizzly or Dabr.
                               Second one method is, if you want to use twitter without letting anyone, you use Quitter, that is a simple twitter client which is run by command prompt or by DOS Window. By Quitter, you can read and reply to tweets, follow/unfollow peoples and you can also manage your Direct messages.
If you use Microsoft Office then Spreadtweet is the best option for you, with this you can receive updates, reply and also your direct messages.