Lab #3: Programming Exercises for Social Web APIs By J. H. Wang Dec. 26, 2011
Outline Twitter/Plurk API Facebook API Other Social APIs
Twitter API To start programming with Twitter API – Document: – Using OAuth to gain authorized access – Start using the three APIs Rest API Search API Streaming API
OAuth (Open Authorization) An open standard for authorization – OAuth 1.0 (RFC 5849) – OAuth 2.0 (work in progress) Allowing users to hand out tokens instead of credentials (username, passwords) – Obtain access tokens to act on behalf of a user account 3-legged OAuth … Authorize all HTTP requests
Example POST /1/statuses/update.json?include_entities=true HTTP/1.1 Accept: */* Connection: close User-Agent: OAuth gem v0.4.4 Content-Type: application/x-www-form-urlencoded Content-Length: 76 Host: api.twitter.com status=Hello%20Ladies%20%2b%20Gentlemen%2c% 20a%20signed%20OAuth%20request%21
With OAuth 1.0a Authorization: OAuth oauth_consumer_key="xvz1evFS4wEEPTGEFPHBog", oauth_nonce="kYjzVBB8Y0ZFabxSWbWovY3uYSQ2pT gmZeNu2VS4cg", oauth_signature="tnnArxj06cWHq44gCs1OSKk%2FjL Y%3D", oauth_signature_method="HMAC-SHA1", oauth_timestamp=" ", oauth_token=" GmHxMAgYyLbNEtIKZeRNFsMKPR9EyMZeS9weJAEb", oauth_version="1.0"
Twitter APIs Rest API – Providing twitter functions: read, write, read DM Search API – Real-time search index Streaming API – HTTP long poll connection
Rate Limits 350 OAuth calls /user /hour /IP Limits on the number of tweets / DMs Limits on the number of follows/unfollows per day
Plurk API 2.0 Document: Sign un a plurk application – Not api_key needed Requests should be signed using OAuth 1.0a JSON encoded Plurk API libraries and OAuth libraries available
Facebook API Login facebook account, and set up new applications Authorization – OAuth Dialog recommended Social channels – Feed, requests,
Facebook Graph API Objects: – E.g.: or – Users, pages, events, groups, applications, status messages, photos, albums, videos, notes, … Relationships – E.g.: / /<CONNECTION_TYPE – Friends, news feed, likes, movies, music, books, notes, tags, groups, …
Searching – &type= &type=<ob j_type – obj_type: post, user, page, event, group, place, checkin Authorization – OAuth 2.0 Graph API Explorer
Facebook Social Plugins Buttons: like, send, subscribe, login Comments, activity feed, recommendations Registration, live stream, …
Other Social APIs Google+ API – GET serId – key: API key – access_token: OAuth 2.0 token – JSON data format
Google Social Graph API – ? & & ?<p aram_1>& &<param_n – Methods lookup otherme testparse geturl
Thanks for Your Attention!