Thursday, 25 July 2013

Twitter Card Validator - server error and automatic retry

I have been implementing Twitter Cards on our sites in last few days. I'm at the stage where everything is implemented however, I do need to get them validated and request for approval.

This you would think is the easiest part of entire development process - that's until you get "Server error, please try again." error and the only reply I have got from Twitter is "we know... keep trying".

So after retrying by hand few times I have decided that I have better things to do with my time; hence the script.

What it does?

  1. Every 10 seconds retry (push retry button).
  2. If you hit rate limiter wait for 10 turns (10 x 10 seconds)
  3. If you pick up that there is no error message then you are finished.

Warning: I have used this to validate some of my Twitter Cards, however I do not give any guarantee that this will work for you and not block your twitter account or cause any other damage.

var tries = 0;
var rateLimit = 10;
var int=self.setInterval(function(){
var button = $("div.icon-refresh");
 var error = $("span.error-label-text:contains('Server error'):visible");
 var rateLimiter = $("span.error-label-text:contains('Rate')");
 // Retry function
 var retryNow = function(){;
  console.log("Attempt: "+tries);
  if(rateLimit <= 0){
   rateLimit = 10;
   console.log("Rate limiter reset to 10 seconds");
 }else if(rateLimiter.length>0){
  console.log("Rate limiter - wait for " + rateLimit + " seconds");
  // Final check for any errors
   console.log("Another error detected re-trying anyway!");


  1. Twitter Account
  2. Chrome / Firefox with Firebug
Figure 3.1


  1. Open your browser (Chrome is my browser of choice) 
  2. Go to URL
    1. Figure 6.1
      Figure 7.3
    2. It might require you to log in, so use your twitter account and login then use the URL to login again.
  3. Pick a card from "Card Catalog" once the page loads. (See Figure 3.1)
  4. Select "Validate & Apply" tab
  5. Enter your site's URL
  6. Wait for "Error to show up" (See Figure 6.1)
  7. Now we are set for running the script
  8. Figure 7.6
    1. Right click the page and select "Inspect Element"
    2. Development tools will appear at the bottom of the page.
    3. Go to the Console tab
    4. Copy / Paste script from above to the console.
    5. Press Enter to start retry.
    6. See figure 7.6 for example output.
    7. Figure 7.7
    8. Once its validated you will get success message. (See figure 7.7)

No comments :

Post a Comment