Party Like It’s 1984
An introduction to social APIs


Jeff Siarto
Co-founder, Loudpixel
APIs are how machines read the web
What are APIs?
★   “Application Programming Interface”
★   We’re talking about web APIs
★   Gives web apps an “interface” ...
APIs are structured
★   Don’t confuse APIs with crawlers and
    robots (GoogleBot)
★   APIs deal with structured data (a ...
JSON
{
    "first_name": "Jeff",
    "last_name": "Siarto",
    "titles": [
        "Partner",
        "Analyst",
        ...
XML
<?xml version="1.0" encoding="UTF-8"?>
   <first_name>Jeff</first_name>
   <last_name>Siarto</last_name>
   <titles>
 ...
REST
★   Representational State Transfer
★   The web is built to utilize REST
★   Stateless
★   HTTP verbs: GET, POST, PUT...
RESTful Web Services
★   Representational State Transfer
★   The web is built to utilize REST
★   Stateless
★   HTTP verbs...
APIs make the social web work
Telescreen
Telescreen
★   Rails 2.3.8
★   Basic mashup using RapLeaf, Twitter,
    Gravatar and Google Maps
★   Search proletarians (...
RapLeaf
# environment.rb
config.gem “rapleaf_api”

# controller
rapleaf = RapleafApi::Api.new(‘API_KEY’)

# find a person
@person ...
RapLeaf Data
★   Basics: name, age, gender, location,
    occupations, schools, earliest/latest
    activity, friend count...
Gravatar
# top of controller
require ‘md5’

# controller method
# MD5 hash the user email address
email_hash = MD5.new(params[:prol...
Google Maps
# build a google maps URI
image_tag("http://maps.google.com/maps/api/staticmap?
center=#{url_for(@person.location)}
&zoom=...
# URI base
http://maps.google.com/maps/api/

# map position and location
staticmap?center=#{url_for(@person.location)}

# ...
Twitter
# top of controller
require 'net/http'
require 'uri'

# Parse Twitter username from RapLeaf
twitter_handle = @person.membe...
# view
@tweets[0]['user']["description"]

# loop through tweets with .each
<% @tweets.each do |t| %>
  <li>
    <%= t['tex...
http://twitter.com/status/user_timeline/jsiarto.json?count=3
Thanks!
Jeff Siarto (jsiarto)
Co-founder, Loudpixel
Jeff Siarto: Party Like It’s 1984, An introduction to social APIs
Jeff Siarto: Party Like It’s 1984, An introduction to social APIs
Jeff Siarto: Party Like It’s 1984, An introduction to social APIs
Jeff Siarto: Party Like It’s 1984, An introduction to social APIs
Jeff Siarto: Party Like It’s 1984, An introduction to social APIs
Jeff Siarto: Party Like It’s 1984, An introduction to social APIs
Upcoming SlideShare
Loading in …5
×

Jeff Siarto: Party Like It’s 1984, An introduction to social APIs

578
-1

Published on

Jeff Siarto, Co-founder Loudpixel: Party Like It’s 1984, An introduction to social APIs for SocialDevCamp 2010

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
578
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
3
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Jeff Siarto: Party Like It’s 1984, An introduction to social APIs

  1. 1. Party Like It’s 1984 An introduction to social APIs Jeff Siarto Co-founder, Loudpixel
  2. 2. APIs are how machines read the web
  3. 3. What are APIs? ★ “Application Programming Interface” ★ We’re talking about web APIs ★ Gives web apps an “interface” for interacting with other software ★ Typically returns data in structured formats like XML and JSON (Jason?)
  4. 4. APIs are structured ★ Don’t confuse APIs with crawlers and robots (GoogleBot) ★ APIs deal with structured data (a user has an name, email and phone) ★ Data is available in a specified format and is usually documented
  5. 5. JSON { "first_name": "Jeff", "last_name": "Siarto", "titles": [ "Partner", "Analyst", "Designer" ], "online": { "website": "http://siarto.com", "twitter": "@jsiarto", "github": "http://github.com/jsiarto" } }
  6. 6. XML <?xml version="1.0" encoding="UTF-8"?> <first_name>Jeff</first_name> <last_name>Siarto</last_name> <titles> <title>Partner</title> <title>Analyst</title> <title>Designer</title> </titles> <online> <website>http://siarto.com</website> <twitter>@jsiarto</twitter> <github>http://github.com/jsiarto</github> </online>
  7. 7. REST ★ Representational State Transfer ★ The web is built to utilize REST ★ Stateless ★ HTTP verbs: GET, POST, PUT, DELETE
  8. 8. RESTful Web Services ★ Representational State Transfer ★ The web is built to utilize REST ★ Stateless ★ HTTP verbs: GET, POST, PUT, DELETE
  9. 9. APIs make the social web work
  10. 10. Telescreen
  11. 11. Telescreen ★ Rails 2.3.8 ★ Basic mashup using RapLeaf, Twitter, Gravatar and Google Maps ★ Search proletarians (users) by email
  12. 12. RapLeaf
  13. 13. # environment.rb config.gem “rapleaf_api” # controller rapleaf = RapleafApi::Api.new(‘API_KEY’) # find a person @person = rapleaf.query(:type => :person, :opts => {:email => ‘steve@apple.com’}) # view @person.location # Chicago, Illinois, United States
  14. 14. RapLeaf Data ★ Basics: name, age, gender, location, occupations, schools, earliest/latest activity, friend count ★ Site Memberships: bebo, facebook, flickr, friendster, hi5, linkedin, livejournal, multiply, myspace, myyearbook, plaxo, twitter
  15. 15. Gravatar
  16. 16. # top of controller require ‘md5’ # controller method # MD5 hash the user email address email_hash = MD5.new(params[:prole]) # build a gravatar URI @gravatar = "http://www.gravatar.com/avatar/# {email_hash}?s=150" # view image_tag @gravatar
  17. 17. Google Maps
  18. 18. # build a google maps URI image_tag("http://maps.google.com/maps/api/staticmap? center=#{url_for(@person.location)} &zoom=12&size=256x256&maptype=roadmap&sensor=false")
  19. 19. # URI base http://maps.google.com/maps/api/ # map position and location staticmap?center=#{url_for(@person.location)} # zoom and size &zoom=12&size=256x256 # map type and sensor &maptype=roadmap&sensor=false
  20. 20. Twitter
  21. 21. # top of controller require 'net/http' require 'uri' # Parse Twitter username from RapLeaf twitter_handle = @person.memberships(:primary)[12] ["profile_url"].gsub("http://twitter.com/", "") unless twitter_handle.nil? # Construct URI uri = URI.parse("http://twitter.com/status/ user_timeline/#{twitter_handle}.json?count=3") # Get JSON @twitter = Net::HTTP.get_response(uri) # Make JSON a Ruby object @tweets = ActiveSupport::JSON.decode(@twitter.body)
  22. 22. # view @tweets[0]['user']["description"] # loop through tweets with .each <% @tweets.each do |t| %> <li> <%= t['text'] %><br /><span class="status-url">< %= link_to(t['created_at'], "http://twitter.com/#{t ['user']['screen_name']}/status/#{t['id']}") %></a> </li> <% end %>
  23. 23. http://twitter.com/status/user_timeline/jsiarto.json?count=3
  24. 24. Thanks! Jeff Siarto (jsiarto) Co-founder, Loudpixel
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×