Difference between revisions of "Emergent Web Technologies Spring 2009 Class 8"

esse quam videri
Jump to: navigation, search
m
m
Line 19: Line 19:
  
 
Try the same thing on some other pages and see what the requests and responses look like.
 
Try the same thing on some other pages and see what the requests and responses look like.
 +
 +
 +
== Activity 2 ==
 +
 +
We're going to create a really simple Twitter client using their RESTful API. You can find the documentation for the Twitter REST API [http://apiwiki.twitter.com/REST+API+Documentation here].
 +
 +
Open up InstantRails and open a new Terminal. Create a new file called "twitter.rb" using a text editor. Make sure that you can find the file using the Ruby console by typing "ruby twitter.rb".
 +
 +
Add the following lines to the very top of twitter.rb
 +
require 'net/http'
 +
require 'rexml/document'
 +
 +
The Net::HTTP library makes it easy to connect to remote server and send HTTP requests to it. REXML is a library for parsing XML. We'll use it to parse the responses from Twitter.

Revision as of 20:33, 18 March 2009

Introduction

This week, I want to give you a quick introduction to HTTP and then show you how a RESTful architecture takes advantage of HTTP to simplify the sharing of resources across the Web.

Activity 1

Make sure that you have the Firebug and Live Headers Firefox Add-ons installed. You can get them here and here.

Go to http://twitter.com and open up the Firebug Console by clicking on the little Firebug in the lower right corner of the browser.

Click on the checkbox next to Net and click the button that says "Apply settings for twitter.com".

Go to the Net tab and reload the page.

You should see a list of requests that were made to http://twitter.com, http://assets0-3.twitter.com and to http://google-analytics.com.

Expand one of the requests to see what the request looked like. Switch between the Headers and the Response tabs to see what the request and response headers and the entity body of the response looked like.

You can also open up the Live Headers add-on to see the requests as they take place.

Try the same thing on some other pages and see what the requests and responses look like.


Activity 2

We're going to create a really simple Twitter client using their RESTful API. You can find the documentation for the Twitter REST API here.

Open up InstantRails and open a new Terminal. Create a new file called "twitter.rb" using a text editor. Make sure that you can find the file using the Ruby console by typing "ruby twitter.rb".

Add the following lines to the very top of twitter.rb

require 'net/http'
require 'rexml/document'

The Net::HTTP library makes it easy to connect to remote server and send HTTP requests to it. REXML is a library for parsing XML. We'll use it to parse the responses from Twitter.