Wednesday, March 30, 2011

Cricket score update - JSON

Hi

I probably should have got this script done long back. If you have a website or a blog where you want to integrate the score update for CWC 2011, then you just need to use the code given below. In this I am using an JSON API of json-cricket.appspot.com for fetching the details. All you have to is parse the JSON returned. The output will be as follows:


This API has not been tested thoroughly, but it surely returns. Here is the code:

For simple HTML

<html>

<head>
<title>Cricket Score Update</title>
</head>
<body>
<div id="score_board"></div>
<script type="text/javascript">
o={s:function(data){document.getElementById("score_board").innerHTML=data.match + "<br />" + data.score + "<br />" + data.summary;}};

</script>
<script type="text/javascript" src="http://json-cricket.appspot.com/score.json?callback=o.s"></script>
</body>
</html>


Blogger Widget:


<b:widget id='Text2' locked='false' title='Score Update' type='Text'>

<b:includable id='main'>
  <!-- only display title if it's non-empty -->
  <b:if cond='data:title != &quot;&quot;'>
    <h2 class='title'><data:title/></h2>
  </b:if>
  <div class='widget-content' id='score_board'>
  </div>
  <script type="text/javascript">
o={s:function(data){document.getElementById("score_board").innerHTML=data.match + "<br />" + data.score + "<br />" + data.summary;}};
</script>
<script type="text/javascript" src="http://json-cricket.appspot.com/score.json?callback=o.s"></script>
  <b:include name='quickedit'/>
</b:includable>
</b:widget>

Cheers!!!

5 comments:

  1. hi my dear friend i want live cricket update linck lick this http://crictime.com/score-card-1.htm .... hi is taken from this linkhttp://www.vcricket.com/indirect/scorecard.aspx?team1=IP-Bangalore&team2=IP-Pune&matchdate=04-29-2011&st=full&t=&o=

    this is my e mail id (raj.shetty8@gmail.com) plz send me thanq ....

    ReplyDelete
  2. I required a complete score card for my wp7 app, if you could kindly run a service for the above, it would be of great help!!

    Things needed:
    Playing teams,
    Batting team,
    score, wicket, run, over
    current over stats i.e. for 5 balls it should be like 0 0 W 1 2

    current batsmen and their
    1. runs scored
    2. balls played
    3. 4s
    4. 6s
    5. SR

    current bowler, and last bowler and their stats
    1. overs bowled
    2. runs conceded
    3. wickets
    4. maiden
    5. Economy rate.

    send me a mail, if you could do it for me.
    mail: cultofdanurag@gmail.com

    ReplyDelete
  3. Things needed:
    Playing teams,
    Batting team,
    score, wicket, run, over
    current over stats i.e. for 5 balls it should be like 0 0 W 1 2

    current batsmen and their
    1. runs scored
    2. balls played
    3. 4s
    4. 6s
    5. SR

    current bowler, and last bowler and their stats
    1. overs bowled
    2. runs conceded
    3. wickets
    4. maiden
    5. Economy rate.

    send me a mail, if you could do it for me.
    mail: amitmaism32@gmail.com

    ReplyDelete