SlideShare a Scribd company logo
1 of 29
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
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

More Related Content

Similar to Introduction to Social APIs

Motion Django Meetup
Motion Django MeetupMotion Django Meetup
Motion Django MeetupMike Malone
 
Tools, Frameworks, & Swift for iOS
Tools, Frameworks, & Swift for iOSTools, Frameworks, & Swift for iOS
Tools, Frameworks, & Swift for iOSTeri Grossheim
 
Apache Sling as an OSGi-powered REST middleware
Apache Sling as an OSGi-powered REST middlewareApache Sling as an OSGi-powered REST middleware
Apache Sling as an OSGi-powered REST middlewareRobert Munteanu
 
Building Apis in Scala with Playframework2
Building Apis in Scala with Playframework2Building Apis in Scala with Playframework2
Building Apis in Scala with Playframework2Manish Pandit
 
Buildingplatforms
BuildingplatformsBuildingplatforms
Buildingplatformscodebits
 
Mashup University 4: Intro To Mashups
Mashup University 4: Intro To MashupsMashup University 4: Intro To Mashups
Mashup University 4: Intro To MashupsJohn Herren
 
Build APIs With Kapow Mashup Server
Build APIs With Kapow Mashup ServerBuild APIs With Kapow Mashup Server
Build APIs With Kapow Mashup ServerAndreas Krohn
 
Goodle Developer Days Munich 2008 - Open Social Update
Goodle Developer Days Munich 2008 - Open Social UpdateGoodle Developer Days Munich 2008 - Open Social Update
Goodle Developer Days Munich 2008 - Open Social UpdatePatrick Chanezon
 
Yahoo! BOSS in Bucharest
Yahoo! BOSS in BucharestYahoo! BOSS in Bucharest
Yahoo! BOSS in BucharestTed Drake
 
創作 MusicKit 告白情歌
創作 MusicKit 告白情歌創作 MusicKit 告白情歌
創作 MusicKit 告白情歌彼得潘 Pan
 
Creating an API with Expressive
Creating an API with ExpressiveCreating an API with Expressive
Creating an API with ExpressiveElton Minetto
 
Finding things on the web with BOSS
Finding things on the web with BOSSFinding things on the web with BOSS
Finding things on the web with BOSSChristian Heilmann
 
Designing a beautiful REST json api
Designing a beautiful REST json apiDesigning a beautiful REST json api
Designing a beautiful REST json api0x07de
 
The liferay case: lessons learned evolving from RPC to Hypermedia REST APIs
The liferay case: lessons learned evolving from RPC to Hypermedia REST APIsThe liferay case: lessons learned evolving from RPC to Hypermedia REST APIs
The liferay case: lessons learned evolving from RPC to Hypermedia REST APIsJorge Ferrer
 
Developing on the aloashbei platform
Developing on the aloashbei platformDeveloping on the aloashbei platform
Developing on the aloashbei platformpycharmer
 
A high profile project with Symfony and API Platform: beIN SPORTS
A high profile project with Symfony and API Platform: beIN SPORTSA high profile project with Symfony and API Platform: beIN SPORTS
A high profile project with Symfony and API Platform: beIN SPORTSSmile I.T is open
 
Graph Analysis over JSON, Larus
Graph Analysis over JSON, LarusGraph Analysis over JSON, Larus
Graph Analysis over JSON, LarusNeo4j
 

Similar to Introduction to Social APIs (20)

Hi5 Open Social
Hi5   Open SocialHi5   Open Social
Hi5 Open Social
 
Motion Django Meetup
Motion Django MeetupMotion Django Meetup
Motion Django Meetup
 
Tools, Frameworks, & Swift for iOS
Tools, Frameworks, & Swift for iOSTools, Frameworks, & Swift for iOS
Tools, Frameworks, & Swift for iOS
 
Apache Sling as an OSGi-powered REST middleware
Apache Sling as an OSGi-powered REST middlewareApache Sling as an OSGi-powered REST middleware
Apache Sling as an OSGi-powered REST middleware
 
Building Apis in Scala with Playframework2
Building Apis in Scala with Playframework2Building Apis in Scala with Playframework2
Building Apis in Scala with Playframework2
 
Buildingplatforms
BuildingplatformsBuildingplatforms
Buildingplatforms
 
Mashup University 4: Intro To Mashups
Mashup University 4: Intro To MashupsMashup University 4: Intro To Mashups
Mashup University 4: Intro To Mashups
 
Build APIs With Kapow Mashup Server
Build APIs With Kapow Mashup ServerBuild APIs With Kapow Mashup Server
Build APIs With Kapow Mashup Server
 
Goodle Developer Days Munich 2008 - Open Social Update
Goodle Developer Days Munich 2008 - Open Social UpdateGoodle Developer Days Munich 2008 - Open Social Update
Goodle Developer Days Munich 2008 - Open Social Update
 
Yahoo! BOSS in Bucharest
Yahoo! BOSS in BucharestYahoo! BOSS in Bucharest
Yahoo! BOSS in Bucharest
 
創作 MusicKit 告白情歌
創作 MusicKit 告白情歌創作 MusicKit 告白情歌
創作 MusicKit 告白情歌
 
Creating an API with Expressive
Creating an API with ExpressiveCreating an API with Expressive
Creating an API with Expressive
 
Finding things on the web with BOSS
Finding things on the web with BOSSFinding things on the web with BOSS
Finding things on the web with BOSS
 
Designing a beautiful REST json api
Designing a beautiful REST json apiDesigning a beautiful REST json api
Designing a beautiful REST json api
 
The liferay case: lessons learned evolving from RPC to Hypermedia REST APIs
The liferay case: lessons learned evolving from RPC to Hypermedia REST APIsThe liferay case: lessons learned evolving from RPC to Hypermedia REST APIs
The liferay case: lessons learned evolving from RPC to Hypermedia REST APIs
 
Developing on the aloashbei platform
Developing on the aloashbei platformDeveloping on the aloashbei platform
Developing on the aloashbei platform
 
xAPI Vocabulary - Improving Semantic Interoperability of Controlled Vocabularies
xAPI Vocabulary - Improving Semantic Interoperability of Controlled VocabulariesxAPI Vocabulary - Improving Semantic Interoperability of Controlled Vocabularies
xAPI Vocabulary - Improving Semantic Interoperability of Controlled Vocabularies
 
Yahoo is open to developers
Yahoo is open to developersYahoo is open to developers
Yahoo is open to developers
 
A high profile project with Symfony and API Platform: beIN SPORTS
A high profile project with Symfony and API Platform: beIN SPORTSA high profile project with Symfony and API Platform: beIN SPORTS
A high profile project with Symfony and API Platform: beIN SPORTS
 
Graph Analysis over JSON, Larus
Graph Analysis over JSON, LarusGraph Analysis over JSON, Larus
Graph Analysis over JSON, Larus
 

Recently uploaded

QMMS Lesson 2 - Using MS Excel Formula.pdf
QMMS Lesson 2 - Using MS Excel Formula.pdfQMMS Lesson 2 - Using MS Excel Formula.pdf
QMMS Lesson 2 - Using MS Excel Formula.pdfROWELL MARQUINA
 
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesAssure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesThousandEyes
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesKari Kakkonen
 
Generative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptxGenerative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptxfnnc6jmgwh
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Alkin Tezuysal
 
Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Kaya Weers
 
Microsoft 365 Copilot: How to boost your productivity with AI – Part two: Dat...
Microsoft 365 Copilot: How to boost your productivity with AI – Part two: Dat...Microsoft 365 Copilot: How to boost your productivity with AI – Part two: Dat...
Microsoft 365 Copilot: How to boost your productivity with AI – Part two: Dat...Nikki Chapple
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfIngrid Airi González
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsRavi Sanghani
 
All These Sophisticated Attacks, Can We Really Detect Them - PDF
All These Sophisticated Attacks, Can We Really Detect Them - PDFAll These Sophisticated Attacks, Can We Really Detect Them - PDF
All These Sophisticated Attacks, Can We Really Detect Them - PDFMichael Gough
 
JET Technology Labs White Paper for Virtualized Security and Encryption Techn...
JET Technology Labs White Paper for Virtualized Security and Encryption Techn...JET Technology Labs White Paper for Virtualized Security and Encryption Techn...
JET Technology Labs White Paper for Virtualized Security and Encryption Techn...amber724300
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfpanagenda
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI AgeCprime
 
Glenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security ObservabilityGlenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security Observabilityitnewsafrica
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...Wes McKinney
 
Transcript: New from BookNet Canada for 2024: BNC SalesData and LibraryData -...
Transcript: New from BookNet Canada for 2024: BNC SalesData and LibraryData -...Transcript: New from BookNet Canada for 2024: BNC SalesData and LibraryData -...
Transcript: New from BookNet Canada for 2024: BNC SalesData and LibraryData -...BookNet Canada
 
QCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architecturesQCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architecturesBernd Ruecker
 
Microservices, Docker deploy and Microservices source code in C#
Microservices, Docker deploy and Microservices source code in C#Microservices, Docker deploy and Microservices source code in C#
Microservices, Docker deploy and Microservices source code in C#Karmanjay Verma
 
Email Marketing Automation for Bonterra Impact Management (fka Social Solutio...
Email Marketing Automation for Bonterra Impact Management (fka Social Solutio...Email Marketing Automation for Bonterra Impact Management (fka Social Solutio...
Email Marketing Automation for Bonterra Impact Management (fka Social Solutio...Jeffrey Haguewood
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Strongerpanagenda
 

Recently uploaded (20)

QMMS Lesson 2 - Using MS Excel Formula.pdf
QMMS Lesson 2 - Using MS Excel Formula.pdfQMMS Lesson 2 - Using MS Excel Formula.pdf
QMMS Lesson 2 - Using MS Excel Formula.pdf
 
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesAssure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examples
 
Generative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptxGenerative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptx
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
 
Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)
 
Microsoft 365 Copilot: How to boost your productivity with AI – Part two: Dat...
Microsoft 365 Copilot: How to boost your productivity with AI – Part two: Dat...Microsoft 365 Copilot: How to boost your productivity with AI – Part two: Dat...
Microsoft 365 Copilot: How to boost your productivity with AI – Part two: Dat...
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdf
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and Insights
 
All These Sophisticated Attacks, Can We Really Detect Them - PDF
All These Sophisticated Attacks, Can We Really Detect Them - PDFAll These Sophisticated Attacks, Can We Really Detect Them - PDF
All These Sophisticated Attacks, Can We Really Detect Them - PDF
 
JET Technology Labs White Paper for Virtualized Security and Encryption Techn...
JET Technology Labs White Paper for Virtualized Security and Encryption Techn...JET Technology Labs White Paper for Virtualized Security and Encryption Techn...
JET Technology Labs White Paper for Virtualized Security and Encryption Techn...
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI Age
 
Glenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security ObservabilityGlenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security Observability
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
 
Transcript: New from BookNet Canada for 2024: BNC SalesData and LibraryData -...
Transcript: New from BookNet Canada for 2024: BNC SalesData and LibraryData -...Transcript: New from BookNet Canada for 2024: BNC SalesData and LibraryData -...
Transcript: New from BookNet Canada for 2024: BNC SalesData and LibraryData -...
 
QCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architecturesQCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architectures
 
Microservices, Docker deploy and Microservices source code in C#
Microservices, Docker deploy and Microservices source code in C#Microservices, Docker deploy and Microservices source code in C#
Microservices, Docker deploy and Microservices source code in C#
 
Email Marketing Automation for Bonterra Impact Management (fka Social Solutio...
Email Marketing Automation for Bonterra Impact Management (fka Social Solutio...Email Marketing Automation for Bonterra Impact Management (fka Social Solutio...
Email Marketing Automation for Bonterra Impact Management (fka Social Solutio...
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
 

Introduction to Social APIs

  • 1. Party Like It’s 1984 An introduction to social APIs Jeff Siarto Co-founder, Loudpixel
  • 2. APIs are how machines read the web
  • 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. 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. JSON { "first_name": "Jeff", "last_name": "Siarto", "titles": [ "Partner", "Analyst", "Designer" ], "online": { "website": "http://siarto.com", "twitter": "@jsiarto", "github": "http://github.com/jsiarto" } }
  • 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. REST ★ Representational State Transfer ★ The web is built to utilize REST ★ Stateless ★ HTTP verbs: GET, POST, PUT, DELETE
  • 8. APIs make the social web work
  • 10. Telescreen ★ Rails 2.3.8 ★ Basic mashup using RapLeaf, Twitter, Gravatar and Google Maps ★ Search proletarians (users) by email
  • 11.
  • 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. 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.
  • 17. # 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
  • 18.
  • 20. # 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")
  • 21. # 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
  • 22.
  • 24. # 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)
  • 25. # 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 %>
  • 27.
  • 28.