MySpace Developer Platform Dive Into OpenSocial Maxwell Newbould Development Manager OpenSocial Container Team, MySpace Seattle
Overview
First Steps… Apply for developer account on Demo Code and Editor OpenSocial on MySpace Developer Platform(MDP) – Container – Owner – Viewer – Profile View – Home View – Canvas View
MySpace Developer Platform OpenSocial – MySpace applications written in JavaScript and/or Flash REST API provides functionality for desktop, mobile, offline, and server to server. Secured using oAuth (
How does OpenSocial fit into MDP? OpenSocial is implemented using a container, entirely client-side. The container is a JavaScript wrapper, which allows applications to communicate with the MDP REST API and MySpace.Com. Applications run inside a jail domain so they are isolated from MySpace.Com.
OpenSocial 0.7/0.8 Basics Javascript container adheres to OpenSocial standard and wraps our RESTful API All extensions live in MyOpenSpace All reference types, property names and defined values are Enums gadgets namespace provides generic support for apps Obtain reference to current container via singleton - opensocial.Container.get()
MyOpenSpace – our Container Exposes extension types and methods Balances XmlHttpRequest connections for you Wraps extended entities and their fields Full docs on developer.myspace.com
DataRequests – Basics Obtain a reference to the Container Create a new DataRequest object Add multiple types of requests to your DataRequest, with optional unique keys Call send() Receive data in your callback
DataResponse – Basics DataResponse.get(keyname).getData() getField(FIELD enum) for individual fields
DataRequests – FetchPerson newFetchPersonRequest(idSpec, param) param[opensocial.DataRequest.PeopleRequestFields.PROFILE_DETAILS] = [opensocial.Person.Field.ID, MyOpenSpace.Person.Field.ABOUT, MyOpenSpace.Person.Field.BOOKS];
DataRequests – FetchPeople newFetchPeopleRequest(idSpec, param) opensocial.DataRequest.Group.VIEWER_FRIENDS opensocial.DataRequest.Group.OWNER_FRIENDS param[MyOpenSpace.DetailType.GET_ONLINE] = true; param[MyOpenSpace.DetailType.GET_STATUS] = true; param[MyOpenSpace.DetailType.GET_MOOD] = true; param[opensocial.DataRequest.PeopleRequestFields.SORT_ORDER] = opensocial.DataRequest.SortOrder.TOP_FRIENDS;
DataRequests – FetchPersonAppData newFetchPersonAppDataRequest(idSpec, keys) VIEWER / OWNER / VIEWER_FRIENDS / OWNER_FRIENDS Keys can be *, or a key name. Values should be JSON strings
DataRequests – UpdatePersonAppData newUpdatePersonAppDataRequest(idSpec, key, value) ONLY VIEWER is supported Key is single key name Value is JSON-encoded data
DataRequests – DeletePersonAppData newFetchDeleteAppDataRequest(idSpec, keys) Only VIEWER is supported Keys can be a single or array of key names. No data in callback
MySpace Extensions newFetchPhoto(s)Request newFetchAlbum(s)Request newFetchVideo(s)Request newFetchPersonStatusRequest newFetchPersonMoodRequest newFetchPersonIndicatorsRequest newFetchPersonFriendshipRequest newFetchPeopleFriendshipRequest What do you want to see come next?
MySpace Extensions PostTo – Profiles – Bulletins – Comments – SendMessage – Blog See PostTo Sample – OpenSocial Extensions app on apps.myspace.com
3 rd Party Content – makeRequest() gadgets.io.makeRequest(url, callback, opt_params) – gadgets.io.RequestParameters – gadgets.io.MethodType GET / POST / PUT / DELETE / HEAD – gadgets.io.ContentType TEXT / DOM / JSON / FEED – gadgets.io.AuthorizationType NONE / SIGNED / AUTHENTICATED
Viral Methods NO INCENTIVIZATION ALLOWED! requestSendMesage – Only message friends – Requires user action – Only send one message per user action requestShareApp – Coming soon – Sends invite to install application to specified recipient
View Navigation – requestNavigateTo Views are found in opensocial.getEnvironment().getSupportedSur faces() Home, Profile, and Canvas views gadgets.view.requestNavigateTo(supported_vi ew, params); params is an object to pass around views – retrieve using gadgets.view.getParams()
Prefs – Localization Support gadgets.Prefs() getLang() – en for English getCountry() - US for USA Full Localization support – resources using en-US
Window – adjustHeight/getViewportDimensions gadget.window.adjustHeight(height) – If no height passed, app will resize to fit content – If height is between 0.0(0%) and 1.0(100%), app will resize based on browser height – If height is greater than 1, resize to that height (pixels) – Upper limits are defined per view gadgets.window.getViewportDimensions – Returns { width: 0, height : 0}
Environment – getDomain/supportsField opensocial.Environment.getDomain() – Returns myspace.com opensocial.Environment.supportsField(objectT ype, fieldName) – objectType is opensocial.Environment.ObjectType – fieldName is string for field name
For more help Irc.freenode.net #myspacedev – Provides JS auto-completion for OpenSocial
Q & A Design Questions? Policy Questions? Architectural / Scaling Questions?