Week 10: JSON and Web Services

1. What happened to XML? – http://www.w3schools.com/xml/xml_whatis.asp

2. Understanding JSON notation – http://www.json.org/

3. Replacement Assignment

Working from the example code below, create a simple application to take and display information from a web services API. Your application should demonstrate an understanding of the JSON object being accessed and an ability to dynamically update the information (not seen in the example below, but built in our example last week.) Any web service can be used for this project. A list of common social media sites and the type of connection and security they require can be found here: http://api-portal.anypoint.mulesoft.com/apis/social-media It would be easiest if you find ones that have either basic or API security.

Your project should…

  • Successfully implement a callback function
  • Pull in data as JavaScript objects
  • Make use of appropriate properties of data
  • Display a portion of imported content
  • Update dynamically at regular intervals
<!doctype html>
<html lang="en">
<head>
 <title>Tweets</title>
 <meta charset="utf-8" />
 <script>
 function updateTweets(tweets) {
 for (var i = 0; i < tweets.length; i++) {
 var tweet = tweets[i];
 var newDiv = document.createElement("div");
 var div = document.getElementById("tweetsHere");
 newDiv.innerHTML = tweet.text;
 div.appendChild(newDiv);
 }
 }
 </script>
</head>
<body>
 <div id="tweetsHere"></div>
 <script src="https://twitter.com/statuses/user_timeline/timoreilly.json?callback=updateTweets">
</script>
</body>
</html>

 

Comments are closed.