1. Trang chủ
  2. » Công Nghệ Thông Tin

Tài liệu Building OpenSocial Apps- P8 docx

50 300 0
Tài liệu đã được kiểm tra trùng lặp

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Tiêu đề Building OpenSocial Apps - Interview with Dan Yue
Tác giả Dan Yue
Trường học University of Social Platforms
Chuyên ngành Social Platform Development
Thể loại Interview
Năm xuất bản Unknown
Thành phố Unknown
Định dạng
Số trang 50
Dung lượng 754,86 KB

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

OpenSocial 0.9† /** * The newFetchAlbumsRequest creates an object for * DataRequest to request albums.. OpenSocial 0.8 on MySpace /** * Creates an object to be used when sending to the

Trang 1

mul-13 What advice, if any, would you offer a first-time app developer?

Don’t expect your “big idea” will make you rich overnight

Dan Yue: Playdom (www.myspace.com/playdom)

1 Who are you?

My name is Dan Yue and I’m the cofounder and CEO of Playdom, the largestgame developer on MySpace Prior to founding Playdom, I was employee num-ber 1 at Adify, an ad network platform acquired by Cox Enterprises in 2008;

founded several wildly unsuccessful technology start-ups; and served as technicalconsultant to Wynn Design and Development … As a lifelong gamer, I’ve playedthousands of hours of Final Fantasy 7 and Baldur’s Gate 2 and spent 34 long days

as a semiprofessional Blackjack player My commitment to the player experienceruns so deep that I wake up several times a night to check the performance ofPlaydom’s games

2 What OpenSocial apps have you created or helped to create?

Playdom has developed and successfully launched 12 apps on MySpace,including seven RPGs Playdom has also launched Poker Palace and BumperStickers on Hi5

3 Is there anything you wish you had known before you started developing your first app?

I wish we realized that games are much more successful on social platforms thanother types of social apps.We first launched Kiss Me on MySpace, which was(and is) a success, but it may have been wiser to launch a game first, then followwith a social app In the perfect scenario, you’d attract a high volume of installswith a highly engaging game; then you can use the first game’s popularity to cross-promote new apps

4 How do you find the MySpace platform, in terms of both technology and growth opportunities?

MySpace is a great platform that provides a lot of possibilities for developers

The average length of visit is longer on MySpace, compared to other social networks, and the emphasis is on self-expression and fun Social games—

and Playdom’s games in particular—work really well in MySpace’s environment

Trang 2

6 What has been your most successful app in terms of number of installs?

How many installs does it have?

Mobsters is the number-1 app on MySpace with over 13.6 million installs

Playdom also has three of the top four apps on MySpace, including Own YourFriends, Kiss Me, and Bumper Stickers

7 What did you try that did and didn’t work to promote your app and increase installs?

We have generally enjoyed great success promoting our apps Our two biggeststrengths: cross-promotions (marketing a new game via a popular established game)and deeply integrating viral channels into our games (the best virals are a naturalpart of the game play)

8 Do you think your app(s) has been successful? Why or why not?

A number of our apps have been successful The most obvious indicator of cess is in the number of installs: Mobsters is the obvious success, our largestMySpace app with over 13.6 installs; and Bumper Stickers is in second placewith over 11 million installs to date However, we really focus on the level ofplayer engagement, and we’re very pleased with our DAU [Daily Active Users]

suc-and length-of-session metrics

9 How did you scale your app once growth took off? Were you prepared,

Thanks to an angel investor, this was possible early in our history

10 Have you tried to monetize your app? If so, how?

Playdom has monetized various apps—and all our RPGs Roughly 60% of ourrevenue comes from direct payments for virtual goods, including in-game advance-ment and limited edition items Five percent of the people playing our games pur-chase virtual goods and the percentage goes up as players spend more time on ourgame.The other half of our revenue is generated via incentivized offers

Trang 3

11 Have you ever spent money advertising your app? If so, where and was it worth it?

We have purchased both sponsorships and cost-per-click banner ads on MySpace

Both have been worth the energy and money because of the return-per-usermetrics they provide.With each user that clicks on the ad, that user brings inadditional players through the app’s viral channels.These advertisements help seedvirality—a critical driver of growth

12 Have you taken advantage of the OpenSocial platform and imported your apps to other social networks like Orkut or Hi5?

Poker Palace and Bumper Stickers have both been successfully launched on Hi5

13 What advice, if any, would you offer a first-time app developer?

New developers need to understand that in today’s market, it’s difficult to gomassively viral by relying on old-school “spammy” methods.Viral channels need to

be authentic to the game, and the game play needs to be fundamentally engaging

We’ve created a formula that speaks to a joint need to drive growth and reducechurn:

G ⫺ cD ⬎ 0 or [Growth ⫺ % of daily churn ⫻ number of daily active users must

be greater than 0]

We’ve fueled growth by identifying the right in-game channels to deploy thevirals.We’ve reduced churn by introducing in-game comments, compellingstorylines, and mini-games

Summary

In this chapter we looked at ways to spread your app, and then how to cash inonce the installs start coming in One thing to take away is that there are individualsand companies out there that are making money by making apps We heard from afew of them in the interviews section and got some tips on how to achieve somesuccess

When it comes to generating income, there is a wide variety of options; this is anexpanding market and one that is interesting for advertisers In terms of getting thebiggest bang for your buck with ads, there are a lot of variables to consider Using one ofthe bigger and more established companies, like Google, is a superior technical solution

You won’t see a lot of downtime with AdSense, for example But AdSense isn’t built totarget social networking apps

On the other hand, RockYou! Ads and Cubics are designed to specifically target thesocial networking user But we encountered technical problems with both ad networks,

so there’s a give-and-take you’ll need to consider

This is one of the most important decisions when it comes to developing andgrowing your app; ultimately you can’t make successful apps if you can’t pay for the

Trang 4

bandwidth So it may take time for you to try different solutions, or a combination ofsolutions Maybe your app is suited for micropayments and you needn’t bug your userswith ads Maybe your golfing app pulls up some great targeted ads via Google AdSenseand you get lots of click-throughs As we’ve seen, it’s easier than ever before to simplydrop an ad into your app and start making money; the sooner you start thinking interms of profit margins, the better

Trang 5

ptg

Trang 6

of going from 0.8 to 0.9 to 0.10.That’s right: zero dot eight, zero dot nine, zero dot ten.

We hope that won’t be the case and that the 0.9 spec will be stable enough that it can

be called version 1.0 without too many changes If that’s what happens, the spec shouldstop churning for a while, excluding a few bug fixes here and there

The other piece of bad news is that MySpace will probably continue to support thelatest and greatest versions of the OpenSocial spec as they are released.That meansversion 0.9 will have the full support of MySpace Sounds great, right?

Well, if your app is currently written in version 0.7, that means you’ll now be twospec versions behind.The more versions that are released and supported by MySpace, themore likely it is that the older versions will receive less and less support.We’re alreadyseeing this phenomenon to some extent Bug fixes and feature releases for 0.7 are fewerand farther between compared to those for 0.8

Fortunately, the good news more than makes up for the bad For the foreseeablefuture, MySpace will continue to support older versions of the OpenSocial spec It’s a lot

of effort to deprecate older versions of the spec, and too many apps are running on oldversions It will happen eventually, but it will probably be a long and drawn-out process

A little-known fact is that the 0.7 container actually also supports OpenSocial 0.6, anearly and buggy release of the spec By the time you read this page, dear readers,version 0.6 will be about two years old (or more)—an eternity in Internet time Ifversion 0.6 can last that long, and probably longer, then version 0.8 will be around for along time as well

Even better news is the fact that when it comes down to it, not a whole lot is ing from version 0.8 to version 0.9.The biggest change will be the inclusion of OSML

chang-to the spec Since we covered OSML extensively in Chapters 10 and 11, we won’t

Trang 7

rehash that topic here.The other big change is what is called “OS Lite,” or the

“Lightweight JS APIs.” OS Lite is, for the most part, a rewrite of the OpenSocialJavaScript APIs and has two main goals: to unify the JavaScript and REST APIs, and touse JSON for both inputs and outputs.These are both worthy goals, but the truth of thematter is that the original APIs will work just fine in version 0.9 Moving forward, OSLite will probably become the standard, but it’s probably best to wait for version 1.0,when it becomes a bit more baked-in

Other than that, there are a few bug fixes, a feature or two, and a bit of a cleanup

Now, let’s take a look at the big changes

Media Item Support

A slew of functions to support media items were added in 0.9; this includes fetches,updates, deletes, and (finally!) uploads However, some of this functionality already existed

on the MySpace platform as MySpace-specific extensions in 0.8

In the sections that follow, we’ll take a look at the new APIs and, if applicable, trast them with the 0.8 APIs.Then we’ll show some sample code so you can see how touse the new features

con-opensocial.Album

The first thing we’ll look at is the new opensocial.Albumobject.The album objectbehaves exactly like the other OpenSocial objects, such as opensocial.Person; it hasfields, and those fields are fetched with getField Let’s take a look at the available fieldsthat albums provide

OpenSocial 0.9*

opensocial.Album.Field = { /**

* String, unique identifier for the album.

* May be used interchangeably with the string 'id'.

* @member opensocial.Album.Field

*/

ID: 'id',

/**

* String, URL to a thumbnail cover of the album.

* May be used interchangeably with the string 'thumbnailUrl'.

Trang 8

/**

* String, the title of the album.

* May be used interchangeably with the string 'title'.

* @member opensocial.Album.Field

*/

TITLE: 'title',

/**

* opensocial.Address, location corresponding to the album.

* May be used interchangeably with the string 'location'.

* @member opensocial.Album.Field

*/

LOCATION: 'location',

/**

* String, ID of the owner of the album.

* May be used interchangeably with the string 'ownerId'.

* @member opensocial.Album.Field

*/

OWNER_ID: 'ownerId',

/**

* Array of MediaItem.TYPE, types of MediaItems in the album.

* May be used interchangeably with the string 'mediaType'.

* @member opensocial.Album.Field

*/

MEDIA_TYPE: 'mediaType',

/**

* Array of strings identifying the mime-types of media items in the album.

* May be used interchangeably with the string 'mediaMimeType'.

* @member opensocial.Album.Field

*/

MEDIA_MIME_TYPE:'mediaMimeType',

/**

* Integer, number of items in the album.

* May be used interchangeably with the string 'mediaItemCount'.

* @member opensocial.Album.Field

*/

MEDIA_ITEM_COUNT:'mediaItemCount' };

OpenSocial 0.8 on MySpace

MyOpenSpace.Album.Field = { /**

* A number representing an album's unique identifier.

Trang 9

* A string representing the album's privacy setting,

* such as "Public" or "Private"

* @memberOf MyOpenSpace.Album.Field

*/

PRIVACY:"PRIVACY",

/**

* An integer representing the total number of photos in the album

* (not the number of photos actually contained

* within the current object).

Trang 10

The entities are basically the same—all the important stuff is there in both cases, such

as IDs, album cover URL, and the number of media items in the album

Fetching Albums

Here’s the functionality for fetching an album First, let’s look at OpenSocial 0.9

OpenSocial 0.9†

/**

* The newFetchAlbumsRequest() creates an object for

* DataRequest to request albums.

*

* @param {opensocial.IdSpec} An IdSpec used to specify which

* people/groups to fetch albums from.

*

* @param {Map.<string, string>} opt_params

* opt_params can specify the following:

* opensocial.Album.Field.ID - an array of album IDs to fetch

* (fetch all albums if empty, subject to pagination)

* opensocial.Album.Field.MEDIA_TYPE - an array of MediaItem.TYPE

* values to specify the kind of albums to fetch.

* opensocial.DataRequest.AlbumRequestFields.FIRST -

* The first item to fetch.

* opensocial.DataRequest.AlbumRequestFields.MAX -

* The maximum number of items to fetch.

* @return {Object} A request object

*/

opensocial.DataRequest.prototype.newFetchAlbumsRequest = function(idSpec, opt_params) {};

And now, the MySpace 0.8 extension

OpenSocial 0.8 on MySpace

/**

* Creates an object to be used when sending to the server

* @param {String} id The ID (VIEWER or OWNER)

* of the person who owns the albums

† Code courtesy of OpenSocial.org: javascript-api-reference/datarequest.

Trang 11

* @param {Map<opensocial.DataRequest.PeopleRequestFields.FIRST ||

* opensocial.DataRequest.PeopleRequestFields.MAX>}

* opt_params Optional parameters specified when creating the albums.

* @return {Object} A request object

* @static

* @memberOf MyOpenSpace.DataRequest

*/

MyOpenSpace.DataRequest.newFetchAlbumsRequest = function(id, opt_params) {};

There are no real functional differences between versions.The new version uses an

IdSpecobject instead of a plain old string ID It can specify a particular album, whereas 0.8had a separate endpoint for that, and the paging parameters are in a different namespace

Here’s an example function that takes in optional paging parameters, album ID, andcallback function and makes a request for the Viewer’s photo albums:

// Fetches the Viewer's photo albums function fetchViewerPhotoAlbums(first, max, album_id, callback){

// Create the IdSpec object var params = {};

params[opensocial.IdSpec.Field.USER_ID] = opensocial.IdSpec.PersonId.VIEWER;

params[opensocial.IdSpec.Field.NETWORK_DISTANCE] = 0;

var idspec = opensocial.newIdSpec(params);

// Create the DataRequest object var request = opensocial.newDataRequest();

Trang 12

In the function we specified opensocial.MediaItem.Type.IMAGE.The otherpossibility is opensocial.MediaItem.Type.VIDEO

Fetching Media Items

Let’s look at the OpenSocial 0.9 method for fetching media items

OpenSocial 0.9‡

/**

* The newFetchAlbumsRequest() creates an object for

* DataRequest to request albums.

*

* @param {opensocial.IdSpec} An IdSpec used to specify which

* people/groups to fetch media items from.

*

* @param {string} albumId

* The ID of the album to fetch MediaItems from.

*

* @param {Map.<string, string>} opt_params

* opt_params can specify the following:

* opensocial.MediaItem.Field.ID - an array of media item IDs to

* selectively fetch (fetch all items if empty, subject to pagination)

* opensocial.MediaItem.Field.MEDIA_TYPE - an array of MediaItem.TYPE

* values to specify the types of MediaItems to fetch

And now for version 0.8

‡ Code courtesy of OpenSocial.org: javascript-api-reference/datarequest.

Trang 13

OpenSocial 0.8 on MySpace

/**

* Creates an object to be used when sending to the server

* @param {String} id The ID (VIEWER or OWNER) of

* the person who owns the albums

* @param {Map<opensocial.DataRequest.PeopleRequestFields.FIRST ||

* opensocial.DataRequest.PeopleRequestFields.MAX>}

* opt_params Optional parameters specified when creating the videos.

* @return {Object} A request object

* Creates an object to be used when sending to the server

* @param {String} id The ID (VIEWER or OWNER)

* of the person who owns the photos

* @param {Map<opensocial.DataRequest.PeopleRequestFields.FIRST ||

* opensocial.DataRequest.PeopleRequestFields.MAX>}

* opt_params Optional parameters specified when creating the photos.

* @return {Object} A request object

* @static

* @memberOf MyOpenSpace.DataRequest

*/

MyOpenSpace.DataRequest.newFetchPhotosRequest = function(id, opt_params) {};

The big difference here is that the 0.9 API combines two MySpace 0.8 APIs intoone, and it again uses an IdSpecobject and modifies the paging parameter namespaces

In our Tic-Tac-Toe app, we had a function that fetched the Viewer’s photos; we’llreproduce it here so that you can see the differences between versions

Version 0.8 Function for Fetching Viewer’s Photos

// Fetch the Viewer's photos function fetchPhotosList(first, max, callback){

// Set the paging parameters var params = {};

params[opensocial.DataRequest.PeopleRequestFields.FIRST] = first;

params[opensocial.DataRequest.PeopleRequestFields.MAX] = max;

// Send the request var request = opensocial.newDataRequest();

Trang 14

Let’s now convert that code into 0.9.

Version 0.9 Function for Fetching Viewer’s Photos

// Fetches the Viewer's photos function fetchPhotosList(first, max, callback, media_id){

// Create the IdSpec object var params = {};

params[opensocial.IdSpec.Field.USER_ID] = opensocial.IdSpec.PersonId.VIEWER;

params[opensocial.IdSpec.Field.NETWORK_DISTANCE] = 0;

var idspec = opensocial.newIdSpec(params);

// Create the DataRequest object var request = opensocial.newDataRequest();

// Add the request to the queue request.add(request.newFetchAlbumsRequest(idspec, params), TTT.RequestKeys.VIEWER_PHOTOS);

Trang 15

// Send it off request.send(callback);

}

Again we specified opensocial.MediaItem.Type.IMAGE, but opensocial.

MediaItem.Type.VIDEOis supported as well

Updating Albums and Media Items

These are APIs that allow you to update the metadata of albums and media items, notactually upload new ones.There are no 0.8 substitutes for these endpoints:§

/**

* Updates the fields specified in the params The following

* fields cannot be set: MEDIA_ITEM_COUNT,

* OWNER_ID, ID Containers implement restrictions.

*

* @param {opensocial.IdSpec} An IdSpec used to specify which

* people/groups to own the album

*

* @param {string} albumId

* The album to update.

*

* @param {Map<opensocial.Album.Field, object>} fields

* The Album Fields to update.The following fields

* cannot be set: MEDIA_ITEM_COUNT,

* OWNER_ID, ID Containers implement restrictions.

*

* @return {Object} A request object

*/

opensocial.DataRequest.prototype.newUpdateAlbumRequest = function(idSpec, albumId, fields){};

/**

* Updates the fields specified in the params The following

* fields cannot be set:

* ID, CREATED, ALBUM_ID, FILE_SIZE, NUM_COMMENTS.

* Containers implement restrictions.

*

* @param {opensocial.IdSpec} An IdSpec used to specify which

* people/groups own the album/media item.

*

* @param {string} albumId

* The album containing the media item to update.

*

§ Code courtesy of OpenSocial.org: javascript-api-reference/datarequest.

Trang 16

* @param {string} mediaItemId

* The media item to update.

*

* @param {Map<opensocial.MediaItem.Field, object>} fields

* The Album Fields to update The following fields cannot be set:

* ID, CREATED, ALBUM_ID, FILE_SIZE, NUM_COMMENTS.

* Containers implement restrictions.

*

* @return {Object} A request object

*/

opensocial.DataRequest.prototype.newUpdateMediaItemRequest = function(idSpec, albumId, mediaItemId, fields){};

Let’s take a look at a quick example.The following function can be used to updatethe title, thumbnail URL, and description of a particular media item in a particularalbum Since the functionality to update an album is very similar, we’ll leave it as anexercise for the reader to create a function to do so

// Updates a media item for the Viewer function updateMediaItem(album_id, media_id, newTitle,

newPic, newDesc, callback){

// Create the IdSpec object var params = {};

params[opensocial.IdSpec.Field.USER_ID] = opensocial.IdSpec.PersonId.VIEWER;

params[opensocial.IdSpec.Field.NETWORK_DISTANCE] = 0;

var idspec = opensocial.newIdSpec(params);

// Create the DataRequest object var request = opensocial.newDataRequest();

// Send it off request.send(callback);

}

Trang 17

Uploading Media Items

One of the big new features added to the spec is the ability to upload media Sendingthe actual contents of an image isn’t very easy in JavaScript, so because of this the uploadfunctionality works similarly to opensocial.requestSendMessageandopensocial.

requestShareApp.You invoke opensocial.requestUploadMediaItemand a pop-upmodal appears.The pop-up itself takes care of the actual uploading process On MySpaceeither a Flash or a Java-based widget is used, depending on the end user’s system Initially,only images are available for upload

Once an image has been uploaded and the user closes the pop-up window, a callbackfunction is executed.The one parameter passed to this callback is an opensocial.

ResponseItemobject.This object contains information on any error that may haveoccurred, or an array of opensocial.MediaItemobjects if there were any successfuluploads

// Comma-delimited list of failed files var error_message = response.getErrorMessage();

// Array of failed files var failed_files = error_message.split(",");

// Retry request? Update UI?

} else{

// Array of MediaItem objects var mi_array = response.getData();

var div = document.getElementById("messages");

var url = opensocial.MediaItem.Field.THUMBNAIL_URL;

for(var i = 0; i < mi_array.length; i++){

div.innerHTML += "<img src='";

Trang 18

div.innerHTML += mi_array[i].getField(url);

div.innerHTML += "' /><br />";

} } }

There are a couple of functions in the code.The first just wraps opensocial.

requestUploadMediaItem.The second is specified as the callback function and handlesthe result of the attempted image upload.The response is checked for an error, and ifone is found, we parse the error field for data.The error code is set as normal and shouldgive you a good idea of what went wrong.The error message is a comma-delimited list

of the files that had an error If there was no error, either the user canceled the pop-upwindow or some files were uploaded

If the upload was successful, the data portion of the response contains an array of

opensocial.MediaItemobjects, one for each successfully uploaded image If the arrayhas a length of zero, you can assume the user canceled the action; otherwise you’re free

to parse the array as you see fit In our case, we simply iterate through the list of imagesand output them to the UI

Simplification of App DataThe functionality of app data has remained constant between versions, but the APIs used

to interact with it have been significantly simplified.The original API was deemed to betoo complex for what was actually allowed For example, it was possible to update theapp data only for the Viewer, yet the function accepted an ID as a parameter eventhough its only valid value was VIEWER

To that end, the signatures for updating and deleting app data were modified.Thefollowing is what they used to look like

Version 0.8 (Updating and Deleting App Data)

opensocial.DataRequest.prototype.newUpdatePersonAppDataRequest = function(id, key, value) {};

opensocial.DataRequest.prototype.newRemovePersonAppDataRequest = function(id, keys) {};

They have now been changed for 0.9

Version 0.9 (Updating and Deleting App Data)

opensocial.DataRequest.prototype.newUpdatePersonAppDataRequest = function(key, value) {};

opensocial.DataRequest.prototype.newRemovePersonAppDataRequest = function(keys) {};

Trang 19

var keys = ["key1", "key2", "key3"];

// Add the list of fields to the parameters params[opensocial.DataRequest.PeopleRequestFields.APP_DATA] = keys;

// ID will be either:

// opensocial.IdSpec.PersonId.VIEWER // or:

// opensocial.IdSpec.PersonId.OWNER var appdata_req = req.newFetchPersonRequest(id, params);

// Add the request to the queue and give it a key req.add(appdata_req, "app_data");

// Send it off req.send(callback);

}

This function fetches the app data for either the Viewer or the Owner First an array

of strings is created with all the app data keys we’d like to fetch—in this case we’d like tofetch three keys.Those keys are added to the parameter object via the opensocial.

DataRequest.PeopleRequestFields.APP_DATAenum.The idvariable can be either

opensocial.IdSpec.PersonId.OWNERoropensocial.IdSpec.PersonId.VIEWER.The request is then sent as normal

Some small modifications are required to fetch the app data for the Owner’s orViewer’s friends.The basic idea is to do everything as we did in the previous codesample but use opensocial.DataRequest.newFetchPeopleRequestinstead Notethat when fetching friends, you need to provide an opensocial.IdSpecobject instead

of a string ID; see Chapter 3, Getting Additional MySpace Data, for details on that

To retrieve the app data in the callback, you must use a function that has been added

to the opensocial.Personobject:**

** Code courtesy of OpenSocial.org: javascript-api-reference/person.

Trang 20

* @param {String} key The key to get app data for.

* @return {String} The corresponding app data.

var val1 = person.getAppData("key1");

var val2 = person.getAppData("key2");

var val3 = person.getAppData("key3");

} else{

// Retry the request?

} }

The values of val1,val2, and val3are the JSON objects that were stored in app dataforkey1,key2, and key3respectively or undefinedif nothing was found for that key

REST APIsFor those of you using iframe apps and the REST APIs, there’s not too much change foryou either.The SDKs will be updated to point to the new APIs, so the change should beinvisible to you Simply get the updated SDKs from the usual place: http://code.google

com/p/myspaceid-sdk/

Replace your existing source files with the new ones If any of this sounds mysterious

to you, check out Chapters 8 and 9 (where we cover OAuth and external iframe apps)for details.That should set you up with hitting the updated APIs Unfortunately, it’s notquite that easy, since the responses of some of the APIs have been slightly modified.Thisdifference in the response between versions exists because the MySpace 0.8 APIs weren’tquite to spec, but now in 0.9 they are So it’s not that the spec changed; it’s just thatMySpace is now compliant Let’s take a look at the two most important APIs, person andfriends, and take a look at how they’ve changed

Trang 21

Meanwhile, a sample response from the 0.8 REST API looks like this:

{

"count": 2,

"Friends":

[ {"name": "Tom",

"largeImage": "http:\/\/path_to_img.png",

"image": "http:\/\/path_to_img.png",

Trang 24

And let’s compare that to the sample response generated by the older API in Chapter 9, External Iframe Apps:

Trang 25

Again, there are quite a few differences Fortunately most of the same data is present

in 0.9, so it’s basically the same data presented in a different way For the friends point earlier, we showed the client-side code modifications necessary to make use of thenew JSON object that will be generated Here we’ll leave it as an exercise for the reader

end-Well, okay … one example In Chapter 9 we requested the Viewer’s data and output allthe fields to the UI.To parse the Viewer’s display name from the response from theREST API, we did this:

sb.append(viewer.fullprofile.basicprofile.name + "<br>");

In the updated 0.9 response, the display name would be accessed like so:

sb.append(viewer.person.displayName + "<br>");

SummaryThere are a few more small tweaks between OpenSocial versions 0.8 and 0.9 comingdown the OpenSocial pipeline, but the bulk of the changes that will directly affect port-ing your apps can be found in this chapter However, this chapter has a couple of “sister”

chapters that deal with the biggest change in 0.9: OSML.To learn more about OSML, seeChapter 10, OSML, Gadgets, and the Data Pipeline, and Chapter 11, Advanced OSML

Ngày đăng: 21/01/2014, 12:20

TỪ KHÓA LIÊN QUAN

w