• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Jeff Siarto: Party Like It’s 1984, An introduction to social APIs
 

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

on

  • 674 views

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

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

Statistics

Views

Total Views
674
Views on SlideShare
674
Embed Views
0

Actions

Likes
0
Downloads
2
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

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

    • 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” for interacting with other software ★ Typically returns data in structured formats like XML and JSON (Jason?)
    • 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
    • JSON { "first_name": "Jeff", "last_name": "Siarto", "titles": [ "Partner", "Analyst", "Designer" ], "online": { "website": "http://siarto.com", "twitter": "@jsiarto", "github": "http://github.com/jsiarto" } }
    • 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>
    • REST ★ Representational State Transfer ★ The web is built to utilize REST ★ Stateless ★ HTTP verbs: GET, POST, PUT, DELETE
    • RESTful Web Services ★ Representational State Transfer ★ The web is built to utilize REST ★ Stateless ★ HTTP verbs: GET, POST, PUT, DELETE
    • APIs make the social web work
    • Telescreen
    • Telescreen ★ Rails 2.3.8 ★ Basic mashup using RapLeaf, Twitter, Gravatar and Google Maps ★ Search proletarians (users) by email
    • RapLeaf
    • # 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
    • 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
    • Gravatar
    • # 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
    • Google Maps
    • # 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")
    • # 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
    • Twitter
    • # 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)
    • # 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 %>
    • http://twitter.com/status/user_timeline/jsiarto.json?count=3
    • Thanks! Jeff Siarto (jsiarto) Co-founder, Loudpixel