TechCrunch Hackathon Douban API

  • 2,554 views
Uploaded on

douban api in hackathon 2011 Beijing

douban api in hackathon 2011 Beijing

More in: Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
No Downloads

Views

Total Views
2,554
On Slideshare
0
From Embeds
0
Number of Embeds
2

Actions

Shares
Downloads
9
Comments
0
Likes
2

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. Douban API laiwei@douban.comhttp://douban.com/people/laiwei 2011-10-29
  • 2. What is Douban• Community• Book• Movie• Music• FM• AlphaTownExplore Life, Express Youself, Share Lifevia http://douban.com/about
  • 3. Why Douban• 50M+ Registered Users• 600+ Cities• 250,000+ Groups• 30000+ Sites• 1000+ Cinemas
  • 4. Douban APIs• Miniblog/Shuo• OpenID• Books/Movies/Music• Photos• Reviews• Collections• Notes• Events• Recommendations• Tags• Dou-mailvia http://www.douban.com/service/apidoc/reference
  • 5. Powered by Douban API• DoubanShuovia http://shuo.douban.com
  • 6. Powered by Douban API• Douban FM• Douban Movie• Douban Bookcart• AlphaTown
  • 7. Powered by Douban API• Third-party Appsvia http://douban.com/service/gallery
  • 8. Douban Open Platform• OpenID• API
  • 9. Douban OpenID• 3rd-party sites and applications can let visitors sign in using their douban id
  • 10. Inside Douban API• using OAuth 2.0 to access douban APIs• The core concepts are simple: – Your application asks for a particular scope of access – Douban displays an OAuth page to users, asking for consent to authorize access to your application – If the user approves, your application will get a shortlived access token that you can use to validate requests for the users data and a long-lived refresh token.
  • 11. Inside Douban API• Today Douban supports three flows of OAuth 2.0 – The client-side flow for JavaScript applications running in a browser – The server-side flow for web applications with servers that can securely store persistent information – The native application flow for desktop and mobile applications
  • 12. Apply Douban Apikeygo to https://www.douban.com/service/auth2/apikey/applythen douban will return a apikey and secret:• apikey="047e255f2309478c0d7a701d691bd6a4"• secret="0253348fa4d10541
  • 13. Modify Apikey Propertiesgo tohttps://www.douban.com/service/auth2/apikey/
  • 14. Client Side Flow1. get access token GET https://www.douban.com/service/auth2/auth? client_id=047e255f2309478c0d7a701d691bd6a4& redirect_uri=http://www.douban.com/& response_type=token& scope=shuo_basic_r,shuo_basic_w2. use access_token access api curl "https://api.douban.com/people/@me" -H "Authorization: Bearer ee905e14b2e427cccbb11a3e18ac7764"
  • 15. Server Side Flow2 steps to obtain access_token
  • 16. Server Side Flow1.get authorization codeGET https://www.douban.com/service/auth2/auth?client_id=047e255f2309478c0d7a701d691bd6a4&redirect_uri=http://book.douban.com&response_type=code&scope=shuo_basic_r,shuo_b
  • 17. Server Side Flow2. get access_token using the code that first step returnedcurl "https://www.douban.com/service/auth" -H "Authorization: Bearer ee905e14b2e427cccbb11a3e18ac7764" -d "client_id=047e255f2309478c0d7a701d691bd6a4&client_secret=0253348fa4d10541&redirect_uri=http://book.douban.com&grant_type=authorization_code&code=12345"
  • 18. Server Side Flow3. use access_token access APIscurl "https://api.douban.com/people/@me" -H "Authorization: Bearer ee905e14b2e427cccbb11a3e18ac7764
  • 19. Native-application FlowThe same as server side flow
  • 20. Q&Athanks