Developing Social-Ready Web Applications #s2gx

Craig Walls – SpringSource

  • working on Spring Social, which is the brains behind Greenhouse (web/mobile conference app for SpringOne)

Socializing Your Applications

  • why would you want to do this?
  • this is where your customers are–lots of people spend a LOT of time on Facebook
    • if they're there, you want to be there with them
  • Facebook–over 500 million active users
    • third largest country in the world
    • 50% log on to Facebook on any given day
    • there's even a movie about it–that says something
  • Twitter — over 100 million users
    • more than 190 million unique visitors monthly
    • more than 65 million tweets per day
  • Others: LinkedIn (80 million members), TripIt (230,000 trips planned per month)
  • More: FourSquare, YouTube (2 billion videos viewed per day), MySpace, Gowalla, Google, Flickr
  • how do you use this to better your application?
    • really depends on the customers and applications
    • don't want to make people come to you, better to interact with people where they already are
    • you can have your customers tell you things about themselves and this data would be hard to get otherwise

Types of Social Integration

  • widgets
    • facebook xfbml/js; the "like" button
      • xfbml — tag library that's interpreted on the client by javascript
    • twitter @anywhere
    • linkedin widgets / linkedin jsapi
      • jaspi resembles xfbml
  • embedded
    • facebook applications
    • igoogle gadgets
    • myspace applications
  • rest api
    • provided by virtually all social networks
    • consumed by external and embedded applications

Widgets

  • facebook connect
    • xfbml tag on page adds the login button to any page (<fb:login-button …>Connect to Facebook</fb:login>
    • demoing "find my facebook friends" functionality (<fb:multi-friend-selector …> — fbml tags that run on the server)
  • twitter @anywhere offers some javascript-based widgets, e.g. follow, connect with twitter
    • can also linkify and hovercard text–does this with a class to add the links and javascript handles adding links (hovercard is the thing that shows the little twitter profile boxes for users)
    • twitter anywhere has great examples in their documentation

Facebook Embedded Applications

  • hosted on your own servers, but look seamless when you're on facebook (look like they're part of facebook)
  • can leverage widgets, REST APIs, javascript apis, etc.
  • most often used for games, quizzes, surveys, etc.

Accessing Social Data with REST Social APIs

  • common operations
    • get user profile
    • get/update status
    • get list of friends
  • specialized operations
    • facebook: create photo album, create a note, etc.
    • twitter: create/follow a list, view trends
    • tripit: retrieve upcoming trips, view friends nearby
  • all done with restful apis
    • most support both json and xml representations

Searching Twitter RestTemplate rest = new RestTemplate(); String query = "#s2gx"; String results = rest.getForObject("http://search.twitter.com/search.json?q={query}", String.class);

  • if you want to get friends on twitter, you get the user IDs back, so you have to make another call back to get info about the user based on the user id

Facebook Graph API

  • interesting form of REST API
  • two basic url patterns
  • if you don't have an authorization key you only get very basic info back (name, gender, country)

Securing Social Data: OAuth is the key to social data

  • most social data is secured behind oauth
  • authentication takes place on social provider
  • consumer application given an access token to access user's profile
    • this gets around having to give another application your login credentials
    • also lets you revoke access for specific applications
  • consumer never knows the user's social network credentials
  • demo of trying to post a tweet without being authorized–throws a 401 error
  • when you sign in via oauth you're signing into the originating application (e.g. facebook) and then facebook tells the application "yes, the provided the correct authentication and have given you permission to do what you told them you were going to do"
    • click "connect with facebook" button from an application
    • box pops up from facebook where the user logs in and grants permissions
    • facebook then makes the connection and gives the application an access key

Comparing OAuth and OpenID

  • openid
    • primary concern is single sign-on
    • shared credentials for multiple sites
    • authentication takes place on your chosen openid server
  • oauth
    • concern is shared data
    • sign into the host application
    • host application then gives some other application access
  • if you sign on via oauth the underlying mechanism could be openid

Versions of OAuth in Play

  • OAuth 1.0: tripit
  • OAuth 1.0a: twitter, linkedin, foursquare, most others
  • OAuth 2: still in draft; early adoption by facebook (not quite full oauth 2) salesforce, gowalla, github, 37signals
    • on target to go final by the end of the year

Signing a request: OAuth 1.0a

  • construct a base string that includes …
    • the http method
    • the request url
    • any parameters (including post/put body parameters if the content type is "application/x-www-form-urlencoded")
  • encrypt the base string to create signature
    • commonly hmac-sha1, signed with api secret
    • could be plaintext or rsa-sha1 (if supported)
  • add authorization header to request

The OAuth 2 Dance — much simpler than oauth 1

  • request authorization from user
  • return to consumer with the authorization code in the request
  • exchange auth code and client secret for access token
  • return access token to consumer for use in REST API calls

Easy Facebook OAuth

  • <fb:login-button perms="email.publish_stream,offline_access">Connect to Facebook</fb:login-button>
  • offline access = the application can access your facebook account at any time
  • oauth 2 gives you the option to create an access token that will expire after a period of time
  • oauth 2 also has a renewal token so you can renew expired tokens, but facebook doesn't support renewal tokens yet
  • if you give the application the "give this app access at any time" it's really just a way to not have the access token expire
    • currently access tokens expire after about an hour
  • once you authorize with FB, you get a cookie back called fbs_appKey (where appKey is your application's key)
    • cookie also includes the access token and user id
  • if you store access tokens in your application's local database, you should store them encrypted
  • once you have the access token, you make the same call to facebook but pass the access token, and then you get a lot more of the profile info from facebook

Social REST API Challenges

  • signing a request for oauth 1.0(a) is difficult when using Spring's RestTemplate
  • each social provider's api varies wildly
  • getting a facebook access token requires parsing the cookie string
  • how should various http response codes be handled?

Spring Social

  • supports social integration in Spring
  • born out of Greenhouse development

TwitterTemplate

  • simplifies signing of OAuth 1 requests through RestTemplate
  • Offers consistent API template-based API across social providers
  • extends spring MVC to offer Facebook access token and user ID as controller parameters
  • maps social responses to a hierarchy of social exceptions
  • Spring Social can get at the actual response to a 4XX error code which you can't get if you're using RestTemplate directly
  • similar to using JdbcTemplate which gives you more detail than the raw sql exceptions
  • Spring Social includes TwitterTemplate to make interacting with twitter much easier

FacebookTemplate

  • a bit simpler since all that's needed is the access token
  • FacebookTemplate facebook = new FacebookTemplate(ACCESS_TOKEN);
  • String profileId = facebook.getProfileId();
  • also linkedin template and tripittemplate

Spring Social Next Steps

  • expanding available operations in social templates
  • more social templates for other providers

Open Source Bridge – Open Source and the Open Social Web

Evan Prodromou, StatusNet Inc.

Communications Revolutions

  • email
    • ca. 1993
      • large consumer systems
      • university networks on internet
      • govt systems
      • proprietary systems inside corporations
      • x.400 – itu recommendation, govt mandated
      • ad-hoc bridges
      • bbses (fidonet)
    • ca. 1995
      • only 18 months later, almost entirely unified around internet email
      • hierarchical addressing – user@domain
      • bbs -> isp
      • aol opens up
      • bbses almost disappeared
      • open source via sendmail was an important catalyst
  • documents
    • ca. 1992
      • proprietary, complex internal systems
      • some file sharing bbses
      • aol, compuserve
      • some ftp systems
    • ca. 1997
      • web documents almost ubiquitous
      • hierarchical addressing
      • intranet/internet/extranet
      • http + html
      • open source via apache is an important catalyst
  • personal publishing
    • ca. 2001
      • "home page" on isp
      • geocities, tripod
      • frontier, blogger
      • rss confusion
      • personal vs. business
    • ca. 2005
      • hosted blogs ubiquitous
      • urls for identity
      • feed readers
      • podcasting (enclosures)
      • rss 1.0, 2.0, atom: more than we need!
      • personal and business — line blurs
      • open source: moveable type, wordpress
  • what's the point?
    • revolutions happen quickly
    • unconnected islands–federated networks
    • commercial adoption drives need for control
    • open source implementation is key
  • why open source?
    • low or no-cost to install
    • bottom-up adoption
      • people with more tech skills than money, not the other way around
    • rapid innovation as things scale
      • open source adopts rapid innovation better than proprietary software
  • what is federation?
    • network of networks
    • open protocols
    • uniform namespace
    • hierarchical addressing
    • anyone can play
  • other federated networks
    • postal system (country + postal code + local addressing)
    • telephone systems
    • sms
    • tcp/ip
    • dns
  • what drives federation on the internet?
    • tcp/ip
    • dns
    • scale
    • globalism
  • what drives federation?
    • control
    • distrust
    • greed
  • metcalfe's law
    • value of network proportional to the square of the number of nodes
    • the more the merrier–much, much merrier
    • "value" is a little vague–depends on the particular network
  • metcalfe's law and federation
    • big networks more resistant to change initially
    • as network of networks gets bigger, puts pressure on the bigger networks to participate
  • social software: 2010
    • facebook: 400M+ users
    • twitter: 100M+ users
    • application-specific networks threatened: flickr, digg, youtube
    • national networks threatened: orkut, friendster, bebo, hi-5
    • niche networks threatened: linkedin, ning
    • social gaming
      • pressure on social gaming developers to use biggest platform
  • one vision
    • some networks become de facto substrate for internet
      • facebook: "open" social graph
      • twitter: social messaging, "real time"
    • "open" means "use our API"
    • "shoot the moon" approach is a doable vision–it does happen
      • skype for voice
      • google for search
  • another vision–federated vision
    • commercial adoption of social messaging
      • businesses looking to share outside their firewall
    • need to connect
    • threatened networks fight to survive
      • one way to survive is to adopt leading networks' social graph
      • another way to survive is through federation
    • open govt requires 100% engagement
      • pay taxes through facebook? twitter as only means to connect to my members of congress?
      • systems need to be open for engagement with citizens
    • business needs of providers
      • hard to run a business using the "we're the X layer of the internet" model
  • Social Software – 2012?
    • email like identity, either email or URL
    • distributed real-time follow
    • combination of small and large networks
      • combo of public/private
    • application-specific networks, e.g. social gaming, photo sharing, etc. will move towards open standards
  • why should hackers care?
    • most important parts of our life: family, friends, romance
      • being social is a huge part of being a human being
    • politics require open discourse
      • need to continue to push for openness
    • making software that matters
      • can have a very large impact
  • protocol suites
    • email has smtp, mime, etc.
    • web = http, html, css, etc.
    • blogging = web, rss, atom, etc.
    • social web = ???
      • what will the protocols be that make up this system?
    • everything is made up of a combination of standards
  • openid
    • http://openid.net
    • authentication
    • url for identity
    • devolving to a few identity providers (google, yahoo)
    • whitelist oriented
  • oauth
    • http://oauth.net
    • authorization
    • widely implemented
    • whitelist oriented (consumer keys)
    • not a lot of social parts
    • authentication (e.g. sign in with twitter)
  • PubSubHubbub
    • http://code.google.com/p/pubsubhubbub
    • real-time publishing ("Pu$H")
    • atom or rss-based
    • web hooks
    • great support: google buzz, posterous, tumblr, wordpress, livejournal, statusnet, cliqset …
      • lots of people prepared to be publisher, not too many prepared to be subscriber
  • activitystreams
    • http://activitystrea.ms
    • represent social actions in atom with xml namespace extension
    • subject, verb, object
    • "evan published a photo"
    • powerful when combined with pubsubhubbub
    • can push activities to people who are interested across the web
  • salmon
  • webfinger
    • http://code.google.com/p/webfinger
    • email-like identity for the web (user@domain)
    • xml document format matches identity to urls (my photo service is x, my social messaging service is Y, my profile is Z …)
    • lrdd uses urls instead of webfingers
  • portable contacts
    • http://portablecontacts.net
    • define social relationships
    • static social graph
    • user-controlled sharing of contact data
    • compare: xfn, foaf
  • ostatus
    • http://ostatus.org
    • combines various protocols — first stake in the ground towards building social web systems
    • created by statusnet
    • webfinger + lrdd = discovery
    • push + activitystreams = follow
    • salmon + activitystreams = reply
    • activitystreams + poco = profile
  • xmpp
    • http://xmpp.org
    • originally developed for IM (Jabber)
    • distributed system with email-like identifiers
    • social relationships = buddy list
    • profile = vcard
    • supports publish-subscribe
    • not widely implemented, not http based
      • can be difficult to work with, but very nicely federated
  • what's missing?
    • privacy
    • client API
    • microapps
  • the open source enabler
    • who will be the apache of the open social web?
    • not sure yet
    • many contenders
      • statusnet is a good start
    • trying to work with others providing open social network code so things work well together
  • diaspora
    • http://joindiaspora.com
    • 4 students in nyc, 1 summer, $200K!
    • ostatus-like stack
    • ruby on rails
    • agplv3
    • no working version … yet
    • very interested in using the stack of existing technologies
    • if they're able to pull this off, they'll be an important part of the federated social web
  • DiSo
    • http://www.diso-project.org
    • based on wordpress
    • chris messina, steve ivy
    • xfn
    • leading activitystreams
    • have had some problems getting traction
  • Elgg
    • http://elgg.org
    • most advanced general purpose social network
    • LAMP
      • any time you use something other than LAMP you're limiting the popularity
    • commercial hosting system http://elgg.com
    • some federation (push), more coming
    • lorea fork/branch leading the way with elgg federation
    • gplv2
  • gnu social
  • buddypress
    • http://buddypress.org
    • general purpose social network
    • automattic project, very nicely done
    • lamp
    • gplv2
    • very little federation
  • statusnet
    • http://status.net
    • microblogging server
    • lamp
    • agplv3
    • ostatus for federation
    • twitter-like api
    • plugin architecture
    • identi.ca + 25K other sites on the web, 1.5 million users
  • onesocialweb
    • http://onesocialweb.org
    • vodaphone project
    • uses xmpp as core protocol
    • java plugin for openfire server
    • one of the worst things that can happen now is competing standards
  • others
    • aroundme
    • appleseed
    • crabgrass
    • noserub
  • what next?
    • projects working together
    • integration testing
    • real-life usage
    • innovation
    • growth
  • how to help
    • hack
    • translate
    • theme
    • implement
    • use
    • spread

Decentralize the web with Diaspora — Kickstarter

Personally I think Diaspora is vital to the future of social networking on the web, so I donated to the project on Kickstarter. The guys behind it are very passionate about the project and I think the goals are amazing: let you share what you want bur your data remains yours. I can’t wait to see where this goes.

Creating a Network Like Facebook, Only Private – NYTimes.com

A few months back, four geeky college students, living on pizza in a computer lab downtown on Mercer Street, decided to build a social network that wouldn’t force people to surrender their privacy to a big business. It would take three or four months to write the code, and they would need a few thousand dollars each to live on.

They gave themselves 39 days to raise $10,000, using an online site, Kickstarter, that helps creative people find support.

It turned out that just about all they had to do was whisper their plans.

And so the backlash begins–I’ve been predicting for a long time that the era of “privacy is dead” wouldn’t last, and the shot heard ’round the world in this case was Facebook’s recent actions around privacy.

I applaud these guys for taking this on. Someone needed to and I think there will be a pretty huge uptake of this before long. Make sure and read the transcript of Eben Moglen’s “Freedom in the Cloud” talk if you haven’t already. Great food for thought.

Interview: Eben Moglen – Freedom vs. the Cloud Log

Free software has won: practically all of the biggest and most exciting Web companies like Google, Facebook and Twitter run on it. But it is also in danger of losing, because those same services now represent a huge threat to our freedom as a result of the vast stores of information they hold about us, and the in-depth surveillance that implies.

Excellent interview with Eben Moglen about the state of freedom in the age of social networking. Make sure to read the second page too–there are some surprisingly revolutionary (and simple!) ideas about how to turn the current situation on its head so we can get the benefit of social networking without giving up so much control and freedom.

Community Equity: Facebook for Enterprise

Community Equity goes beyond a simple structuring of people and their online content. Community Equity performs complex calculations to rate one’s participation and contribution levels, the ultimate goal being to drive the adoption of content and ideas, which provides an ideal platform for corporate communities.

Interesting open source “Facebook for Enterprise” application by Sun. Could be just the ticket who want Facebook internally but also want something a bit more business oriented in addition to the social aspects.

IBM is its own open-source lab for social software

Jeff Schick, IBM

(Credit: Jeffrey Gluck, IBM)

Most vendors must guess what customers want to buy, and how they’ll use it. For IBM, however, with about 400,000 employees, it has the potential to be its own best laboratory, one that becomes even more potent when mixed with active participation in open-source communities.

That potential, as I discovered in an interview on Friday with Jeff Schick, IBM’s vice president of social software, isn’t a “gimme,” but is powerful if you can enable the right sort of corporate culture and processes.

For example, Schick mentioned that IBM has a technology adoption program for employees that spans the gamut of new products, add-ons and patches to existing products, and still-raw technologies direct from IBM’s labs. While the invitation list and process is different for each particular item, IBM generally encourages its product groups to “experiment” upon each other. The earlier in the development process, the better.

At the heart of this open approach to technology adoption are open standards and open source. When I pressed Schick on the relative importance of both (“If you could only choose open standards or open source, which would it be?”), he responded:

Our products may include open-source components, and often do, but ultimately open standards are the most important consideration for customers. As customers integrate our products into their various enterprise systems, open standards are critical for ensuring they work.

Point taken, but it’s impressive just how much open source influences IBM’s product development. Gartner estimates that 80 percent of commercial applications will include open-source components by 2012. At IBM, the number may even be higher.

Despite IBM not releasing its core software products under open-source licenses, Schick noted just how integral open source is to IBM:

From a development perspective, as we build our social software products in Lotus, we’re always looking at ways to improve quality and time-to-market. Open source often helps us with both areas.

For example, we were blogging within IBM for a long time before deciding to build the Lotus Connections product, which is fast approaching hundreds of millions of users. After some study, we decided to build the blogging piece of Lotus Connections using the Apache Roller project, an open-source Java blog software. We have become active contributors to the project since then.

But it’s not just in Lotus Connections. As you look across nearly every capability across our social-software strategy, open source plays a critical role. Open source is an integral part of how we build products. Our engineers are very much in tune with the wide variety of open-source components that are available to them, and use and contribute to them. Regularly.

IBM seems to have figured out better than most how to marry the global open-source laboratory with a massive internal laboratory. Talking to Schick, there appears to be a very blurry line between “internal” development and “external” development, giving the company a significant advantage over proprietary (Microsoft) and open-source (Liferay, Open-Xchange) competitors alike.

Some competitors may be able to match IBM’s scale, but few to none have managed to marry internal scale (employees) with the power of external scale (open-source communities) in the way that IBM has.

Follow me on Twitter @mjasay.