310 likes | 820 Views
Access Xbox LIVE Using RESTful Web Services. Martin Sleeman Senior Program Manager Microsoft. Talk Overview. RESTful Service Introduction Companion Apps and RESTful Services RESTful Service overview Authorizing against Xbox LIVE Services Example of accessing a profile Demo Summary
E N D
Access Xbox LIVE Using RESTful Web Services Martin Sleeman Senior Program Manager Microsoft
Talk Overview • RESTful Service Introduction • Companion Apps and RESTful Services • RESTful Service overview • Authorizing against Xbox LIVE Services • Example of accessing a profile • Demo • Summary • Questions
What are RESTful Services Anyways? • RESTful Services: • REST stands for Representational State Transfer • It is not a standard or a RFC, rather it is an architectural style that the leverages HTTP(s) protocol • Each unique URI is a representation of an resource • APIs based on four http verbs: GET, PUT, POST, DELETE to manipulate the resources defined by the URI • Responses can use XML or JSON • JavaScript Object Notation (JSON) • A lightweight text-based human readable open standard designed for data interchange1 1 http://en.wikipedia.org/wiki/Json
Hello World RESTful Style I’m modeling a bookshelf where each book’s ISBN number is its unique book id. Let’s Get the author of a book I wrote (ISBN 12345) REQUEST GET http://www.contoso.com/books/book_isbn({12345})/author HTTP/1.1 Host: contoso.com … RESPONSE HTTP/1.1 200 OK … Date: Mon, 27 Jun 2011 16:08:26 GMT Server: Microsoft-IIS/7.0 … { "author": "Martin Sleeman" }
Updating an Author RESTfully Let’s update name of that author by putting a new value there. REQUEST PUT http://www.contoso.com/books/book_isbn({12345})/author HTTP/1.1 User-Agent: Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0) Host: contoso.com … Martin John Sleeman RESPONSE HTTP/1.1 200 OK Proxy-Connection: Keep-Alive Connection: Keep-Alive Date: Mon, 27 Jun 2011 16:08:26 GMT Server: Microsoft-IIS/7.0 …
RESTful Access to Xbox LIVE • Why support RESTful Services? • Simple and easy to use (just construct URLs with sprintf) • Many clients speak HTTPS • Easy cross platform communication • We can innovate and & release services more quickly • It scales and caches very well • Focuses design on the cloud with multiple screens • How can they help me? • 3 screen Title Managed Storage • 3 screen Asynchronous multiplayer
Companion Games • Companion games extend franchises • Mobile applications, web sites, or even Arcade games • Companion games can: • Extend the story line • Give starting advantage to players • Give the players more loot or experience points. • Transfer of loot between the companion game and full game • Allow Abilities or enhanced items
Why Do Them • Generate pre-launch buzz • Keep players engage over a longer period of time • The continued engagement with the brand generates: • More word of mouth recommendations • Greater revenue opportunity • Companion games have a much shorter lag between the release date of the companion game and the full game • Now for some examples…
Fable II: Pub Games Step 1. Purchase pub game Step 2. Play the Gambling mini games Step 3. Profit… straight to your Fable II character.
Toy Soldiers & MDTS • War Takes Money… • Contributions count toward the same war • Facebook player gets buff after playing the Xbox 360 game • Xbox 360 player gets 50% more health in Survival from Facebook
Companion Game Considerations… • The game lives in the cloud • Each device is a window into the same game • Simplicity • The experiences work together...period • Experience progress seamlessly across devices • Everything counts • Even if you only play for 5 minutes, it helps • Complete experience • It has to stand on its own as a fun game, it’s not just a moving ad • How do you experience the game when your companion device is next to you? • Inclusive Recruitment • Make it easy to keep selling the user on the game and tell their friends • Don’t assume simultaneous shipping of all your platforms
Are Companion Games Difficult? • Cross-platform sharing is hard • Multiple authentication methods • Servers required for XLSP
Companion Games with REST are Much Simpler! • No XLSP Servers required • Instead use simple HTTP-based RESTful services from more clients much more easily.
RESTful Roadmap XBL RESTful Map Facebook Posting Social Storage Users Aggregation Avatars You are here Multiplayer Activities
RESTful API Overview 2011 • Below is the list of 2011 RESTful APIs. We’ll be expanding these services over time. • Root URL is https://services.xboxlive.com /Aggregation • It’s a super scalable, near real-time, aggregated key-value store • Currently powers ESPN voting • Enables heat maps and voting scenarios in your game or video application /Activity • View Leaderboards /Matchmaking & /Multiplayer • Enables asynchronous matchmaking and multiplayer across platforms. /Storage • Title Managed Storage. More space accessible, more often /Users • Get & Set Profile information • Get & Grant achievements • Avatar Read (no writes) • Get Titles played by the user
What I’m Covering in this Talk… /Users • Get & Set Profile information • Get & Grant achievements • Avatar Read (no writes) • Get Titles played by the user Other APIs will be covered in depth in other talks
/Users Namespace Base URI: https://services.xboxlive.com/
Reading Titles • https://services.xboxlive.com/users/xuid{xuid}/titlehistory?skipItems=1&maxItems=2 JSON: { “userTitles": [ { “currentAchievements":0, “currentGamerscore":0, “lastPlayed":"2011-06-03T15:27:00Z", “titleId":1297287259, “titleName":"Halo: Reach", “totalAchievements":59, “totalGamerscore":1400, }, { …. } ] }
Reading Achievements • Read an achievement from the current user https://services.xboxlive.com/users/xuid({xuid})/progress/achievements?skipItems=1&maxItems=3 JSON: {"Achievements": [{“achievementId":28, “achievementOptions":1114112, “achievementType":1, “description":"You unlocked The Kid!", “gamerscore":10, “imageId":10, “timeAchieved":"2011-06-03T15:27:00Z", “title":"The Kid", “titleId":1480657498, “unachieved":"Find and unlock The Kid."}, … ] }
Accessing RESTful Xbox LIVE Services • Console • You may call these new RESTful APIs directly • Existing APIs will continue to be supported through the XDK • Windows Phone • Existing APIs continue to be supported through XNA • You may call our new RESTful APIs • Web • Register your web site • Use our new authentication model • Use the new RESTful web services directly
Authentication Model Overview Security Token Service (STS) Trust 2. Get STS Token STS Token WLID ticket Authenticate (prove your identity) Client 3. Send STS Token to access services STS Token
Windows Phone Accessing New XBOX Live Services Security Token Service (STS) 0. Trust Partner Token New audience URI WLID ticket 2. Get Partner token (works like a STS token) Windows Phone Device cert 1. Call Gamer.GetPartnerTokenwith ‘New’ Audience URI Windows Phone App 3. Send STS Token with RESTful calls to access services Partner Token
Considerations • We will prevent abuse of our services through TCRs. • Limits on the number of multiplayer messages sent per day • Work with your Account Manager on your capacity plan • Each platform version of a title will have its own titleid.
Web Companion App Demo Web Site Demo
Call to Action Get the information you need… Get tools & information @ https://developer.xboxlive.com Get started… • Talk to your Account Manager to get set up! • Start experimenting • Tell us what you would like to see… Need help? • We’re here for you… • Contact your Account Manager for assistance