Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống
1
/ 50 trang
THÔNG TIN TÀI LIỆU
Thông tin cơ bản
Định dạng
Số trang
50
Dung lượng
663,08 KB
Nội dung
ptg
Managing Your App
Once your app is live, you can hide it, publish changes to the code, or delete it.
Hiding and Deleting an App
When you hide an app, you change the status of the application to “Hidden.”This
only stops your app from showing up in search results in the apps gallery
(http://apps.myspace.com). It does not hide the app from users who already have the app
installed.
Warning
The only way to hide an app from users who already have the app installed or force an
uninstall is to delete the app. Hiding the app does not hide it from existing users.
If you want to delete an app, click Delete.You will be prompted with a confirmation.
Click Yes and the app will be deleted.
Making Changes to a Live App (Multiple Versions)
Once your app has gone live, there are two versions of it:
n
Development version
n
Live version
When you click Edit App Source on a live app, you see two links: Dev App and Live
App at the bottom of the screen (as shown in Figure 12.7).
274 Chapter 12 App Life Cycle
Figure 12.7 Dev App and Live App selection options.
From the Library of Lee Bogdanoff
Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.
ptg
Your Live version can’t be edited directly.You must edit your source code on the
Development version. Any changes are immediately reflected in the Development
version and don’t appear in the Live version until the app is republished.When you’re
testing or viewing your Development version, you should see &appvers=dev at the end
of the app’s URL, as shown in Figure 12.8. So, if you ever want to see the Development
version of your app, just append &appvers=dev to the end of the query string for the
surface you’re currently viewing.
Republishing a Live App
You’ve changed your code, tested it, made some improvements, and you’re ready to release
version 1.1; now what? Click Publish Changes to start the review process over again.
Changing the App Profile/Landing Page
When users discover your app in the app gallery or through a friend’s page, they’ll click
on your app link and be taken to your app Profile page.This is like a landing page, and it
contains that magical button that you want everyone to click: Add This App.
To see what your app’s Profile looks like, go to the Canvas page and click More Info at
the top of the page. Now, do you see a boring default surface with little more than the
basic details? Or something that looks more like the landing page shown in Figure 12.9?
This is one area that developers often overlook, but it’s very important.The app’s
Profile is the first introduction of a potential user to your app, so you should try to sell
your app here in order to turn a potential user into a user.You’ll notice that the large
professional app development companies have polished-looking app Profile pages.
Managing Your App 275
Figure 12.8 Note the &appvers=dev at the end of the URL in the
address bar.
From the Library of Lee Bogdanoff
Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.
ptg
Common tweaks include making the Add This App button larger, adding branding, put-
ting up screen shots of the app in action, and just generally making the page more appeal-
ing to prospective installs. Editing your app Profile page is similar to the way users “bling
out” their MySpace Profile pages, and you’re under the same restrictions.That means no
JavaScript, but you can modify CSS and add image, anchor, and various style tags, like bold.
To edit the app Profile page, you must first log in to MySpace as the app (not as the
developer), click Edit Profile, then click the CSS tab. Inside the CSS box you can put
any valid CSS.You can hook your CSS styles into existing elements on the page using
their IDs or element types. For example, the Add This App button has an ID of
profile_appinstall_button, so you can style it using the # CSS selector. Some
other useful element IDs are found in Table 12.1, and you can use Firebug or view the
source of the page to see all the markup on the page.
Another option is to add custom HTML elements to the About section. Inside the
Edit Profile page click the About tab; inside the box you can add HTML elements
including
<img> and <div> tags. If any of the tags have a class attribute, you can add the
class definition into the CSS markup under the CSS tab.
Here’s an example of how we spiffed up the Tic-Tac-Toe app Profile. First, let’s look
at the About section:
<div class="ttt_about_wrap">
<div class="ttt_img">
<img src="http://c3.ac-
images.myspacecdn.com/images02/3/l_0acdd89ec98c4b7db244ed0ab1371e06.png"/>
</div>
<div class="ttt_text">
276 Chapter 12 App Life Cycle
Figure 12.9 App Profile page for iLike (http:/myspace.com/ilike),
a popular application.
From the Library of Lee Bogdanoff
Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.
ptg
<p>The game that’s sweeping the world!</p>
<p>
Features:
<ul>
<li>Custom backgrounds!</li>
<li>Challenge friends!</li>
<li>Play the computer!</li>
</ul>
</p>
<p>Click the Add this App button above to play now!</p>
</div>
<div class="clear"></div>
</div>
Then the CSS section:
body{
background-image:url(http://c1.ac-
images.myspacecdn.com/images02/31/l_e98f74e73ace46f2939c2de7322fcce4.png);
}
#profile_appinstall_button{
background-color:#1E4C9F;
border:solid 5px #0cf;
color:White;
font-family:Verdana;
font-size:28px;
Managing Your App 277
Table 12.1 CSS Selectors in MySpace
CSS Selector HTML Element
#profile_appinstall_button{} Add This App button
#mainLayout{} Main container for the contents of the Profile;
doesn’t include the header or footer of the
page or the gray (by default) background
#profile_appdetail{} Container for the top left portion of the Profile,
including the app’s icon, developers, num-
ber of installs, and categories
#profile_appinstall{} Container for the top right portion of the
Profile; includes the Add This App button
#profile_aboutMe{} Container for the bottom portion of the Profile,
from “About [app name]” to above the forums
#profile_forums{} Container for the forum links
body{} The body element for the page, useful for
modifying the background color and image
From the Library of Lee Bogdanoff
Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.
ptg
padding:10px;
}
.ttt_img{
float:left;
}
.ttt_text{
font-family:Verdana;
font-size:18px;
}
.ttt_text ul{
list-style-position: inside;
text-indent: 20px;
}
.clear{
clear:both;
}
The final product is shown in Figure 12.10.
Tip
You’ll notice that in both our CSS and About sections we include images. To save on
hosting and bandwidth costs, both images are hosted by MySpace. While logged in as the
app to edit the Profile, we uploaded the photos through the Upload link on the Home page,
just as normal users would upload their photos. Once the photos are uploaded, you can
view the source of the image by right-clicking it and selecting Properties. Voilà! Free image
hosting for MySpace apps!
278
Chapter 12 App Life Cycle
Figure 12.10 Updated Tic-Tac-Toe app Profile page.
From the Library of Lee Bogdanoff
Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.
ptg
Managing Developers
We already know how to edit the source code, details, and templates, but you can also
use the developer platform to manage multiple developers. By clicking the Developers &
Testers option under an app on the My Apps page, you can add and delete codevelopers.
Once you click on Developers & Testers, you will be shown your friend list.To be
added to your app, the developer must first be your MySpace friend. He or she must also
be an approved developer; all of the approved developers in your friend list will have a
gear icon under their pictures.To add a friend as a developer, click and drag his or her
picture box into the Developers column.To remove the friend as a developer, simply
click on the red circular icon in the Developers column next to the friend’s name.
Before you grant developer status to anyone, it’s recommended that you back up your
source code with every version of the app.
Note
You can’t set specific permissions for each codeveloper. Once someone is added as a
developer to an app, the person can install the app in development status, make changes
to the code, and even submit the app for publishing. However, the person can’t delete the
app, add other developers, or acknowledge feedback. For example, if your app is denied
publication because of an error, only you, the original developer, may acknowledge feedback
and revert it to a ready-to-publish status.
There’s one last kick in the pants. As long as you’re someone’s friend and an approved
developer, that person can add you as a developer to his or her app and you can’t say no
or remove yourself as a developer.The app creator must remove you. So, if someone adds
you as a developer on a questionable app, such as a Battlestar Galactica Sucks app, your
name will be attached to it publicly unless you ask the original creator very nicely to
please remove you as a developer.
Managing Testers
You may want to have a few people test your app before you make it live, or test it
yourself on different accounts.That’s smart. So, how do you do it? From the My Apps
section of the developer platform, click the Developers & Testers link.You’ll be shown a
list of your friends alongside a Developer column and a Test Users column. Simply drag
and drop your friends over to the Test Users column to add them as testers. Once added,
they’ll have instant access to your app in progress.
Event Handling—Installs and Uninstalls
The concept of signed data calls was covered extensively in Chapter 8, OAuth and
Phoning Home, and it really comes into play here with an app’s Install Callback URL
and Uninstall Callback URL.These two settings fields can be found under the Edit
Details tab of your app and are shown in Figure 12.11.
Basically, whenever a user installs or uninstalls your app, MySpace makes a signed
request to these URLs and passes the user’s ID. So, other than the OAuth signature, it
Managing Developers 279
From the Library of Lee Bogdanoff
Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.
ptg
sends only one piece of information, the user’s ID.What you then choose to do with
that piece of information is up to you.
Some apps use the user IDs to simply track who has the app installed. Others may use
them to create profiles for all the users and add them to an off-site database.Again, how
you use the ID that’s passed in to your callback URLs is your decision.
Suspension and Deletion of Your App
Suspension is pretty rare in the world of MySpace apps. If an app violates the Terms of
Use and gets past the reviewers, the app developer usually receives a warning before the
app is suspended or shut down.The developer then has 24 hours (or however long is
specified in the violation notice) to fix the problem.This is not set in stone, and if an
app grossly violates the Terms of Use, or the law, it can be suspended immediately.
Any suspension or violation notices are sent to the e-mail of the app’s creator (not
the app’s e-mail address or the e-mail address of any codevelopers), so make sure you
monitor your app developer e-mail address.
Warning
If your MySpace account is deleted for violating the MySpace Terms of Use, you will not be
able to log in and manage your application. Even getting your now-orphaned application
deleted can be a major headache. There is a work-around for this, though—don’t violate
the Terms of Use.
If your app is suspended, you need to fix the problem before the app is reinstated. So,
while you can appeal on the forums, there is no quick fix if your app breaks the rules.
280 Chapter 12 App Life Cycle
Figure 12.11 Callback URL settings.
From the Library of Lee Bogdanoff
Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.
ptg
Summary
If your app works and doesn’t violate the Terms of Use, you should have no problem
getting it published and up and running. However, in the rare instance that an app is
incorrectly flagged, we hope this chapter will help you navigate the ins and outs of app
publishing.
Remember, though, that it’s easier to catch flies with honey, so be courteous when
dealing with the developer relations team.
Note
Code listings and/or code examples for this chapter can be found on our Google Code
page under http://opensocialtictactoe.googlecode.com.
Summary 281
From the Library of Lee Bogdanoff
Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.
ptg
This page intentionally left blank
From the Library of Lee Bogdanoff
Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.
ptg
13
Performance, Scaling, and
Security
We’re going to delve into some of the more esoteric aspects of building your app
empire. It’s one thing to build a “Hello World” app, or even put together a small mashup.
It’s something else entirely to build an app that becomes an everyday part of life for over
a million people. Consistent performance and user trust become some of the most
important aspects of your app.
This chapter is not an exhaustive study of Web app performance. If you want to study
Web app performance, there are many resources online.Yahoo! Developer Network has
done some excellent research into performance and publishes the information online.
You could also pick up any number of books on performance, such as High Performance
Web Sites by Steve Souders. It is a large topic worthy of several books.We are, however,
going to cover some of the basics, such as the difference between performance and
scaling of an application and some design hints to improve your app’s ability to grow.
Performance and Responsiveness
To start this discussion we’re going to explore different aspects of performance.
Performance is an overloaded term. Cars are often said to have good performance when
they can reach top speed quickly and handle tight turns without sliding off the road.
Another less common but equally correct statement is that a car has good performance if
it gets good gas mileage and can travel long distances on a limited amount of fuel.
People are often said to perform well on the job if they are able to handle multiple
competing priorities simultaneously. It’s not that anything is getting done fast, but that
lots of things are getting done.
What Is Responsive Performance and What Is Scale
Performance?
Performance is generally discussed in terms of how responsive a system is:“When I click
the button, does something happen immediately?”To borrow from the auto industry,
responsive performance is your “zero-to-60” measure. If your app is like my boss’s
From the Library of Lee Bogdanoff
Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.
[...]... much as “Size your images” and “Make pages smaller” were in the late dot-com days Responsive OpenSocial App Performance Guidelines There are also some less obvious guidelines that are specific to writing OpenSocial apps These rules will help your app be more responsive when dealing with fetching and working with OpenSocial data Following these guidelines will also help your app perform consistently and... us here for the example The same rules apply for any piece of data being requested via the OpenSocial framework.The difference is that the performance ramifications are much more noticeable.Take the case of requesting the Viewer: function getViewer(myCallback){ var req = opensocial. newDataRequest(); var id = opensocial. IdSpec.PersonId.VIEWER; req.add(req.newFetchPersonRequest(id), "viewer"); req.send(function(data){... like this: var pageSize = 4; var curPage = 0; function loadFriendsPage(){ var dataReqObj = opensocial. newDataRequest(); var viewerReq; var viewerFriendsReq; var startNum = (curPage * pageSize) + 1; var idspec = opensocial. newIdSpec( {userId : 'VIEWER', groupId : 'FRIENDS'}); var requestOpts = {}; var fldEnum = opensocial. DataRequest.PeopleRequestFields; requestOpts[fldEnum.MAX] = pageSize; requestOpts[fldEnum.FIRST]... "viewerFriendsReq"); dataReqObj.send(loadFriendsPageCallback); var prev = document.getElementById("prevLink"); if(curPage == 0){ prev.className = "pageaction disabled"; } else{ prev.className = "pageaction enabled"; } } function loadFriendsPageCallback(data){ var elem = document.getElementById("currentFriends"); var label = document.getElementById("pageHeader"); var fData = data.get("viewerFriendsReq").getData();... friend list: var pageSize = 4; var curPage = 0; var allMyFriends = []; function loadFriendsInfo(){ var dataReqObj = opensocial. newDataRequest(); var viewerReq; var viewerFriendsReq; var idspec = opensocial. newIdSpec( {userId : 'VIEWER', groupId : 'FRIENDS'}); var requestOpts = {}; var fldEnum = opensocial. DataRequest.PeopleRequestFields; requestOpts[fldEnum.MAX] = 100; requestOpts[fldEnum.FIRST] = 1; viewerFriendsReq... startNum + pageSize; label.innerHTML = "Friends " + startNum + " to " + endNum; var items = ""; fData.each(function(person){ var src = person.getField (opensocial. Person.Field.THUMBNAIL_URL); items += ""; items += person.getField (opensocial. Person.Field.NICKNAME); items += ""; }) elem.innerHTML = items; } function getPreviousFriends(){ if(curPage < 1){ return; } curPage... if(data.hadError()){ var err = "error: " + fData.getErrorMessage() label.innerHTML = "error: "; return; } fData.each(function(person){ var src = person.getField (opensocial. Person.Field.THUMBNAIL_URL); var item = ""; item += person.getField (opensocial. Person.Field.NICKNAME); allMyFriends.push(item); }); showCurrentPage(); } You may notice that the code for these two methods is actually... the data retrieval methods and in the showCurrentPage method.This separation of concerns leads to more efficient and maintainable code function showCurrentPage(){ var elem = document.getElementById("currentFriends") var label = document.getElementById("pageHeader") var startNum = (curPage * pageSize) + 1; var endNum = startNum + pageSize; label.innerHTML = "Friends " + startNum + " to " + endNum; var... Bogdanoff 300 Chapter 13 Performance, Scaling, and Security Rule 2: Test OpenSocial DataResponse Objects for Errors Too often developers consider a single pass of success a sign that they are finished coding Just because you finally got your app to read the Viewer’s photos does not mean you are finished Far from it.There are many, many ways an OpenSocial endpoint may fail Here are a few examples: n n n n n... if(startNum < allMyFriends.length){ for(var i=0; i < pageSize; i++){ if((startNum + i) >= allMyFriends.length ){ break; } items += allMyFriends[startNum+i] + ""; } } elem.innerHTML = items; var prev = document.getElementById("prevLink"); if(curPage == 0){ prev.className = "pageaction disabled"; } Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark From the Library of Lee Bogdanoff . dot-com days.
Responsive OpenSocial App Performance Guidelines
There are also some less obvious guidelines that are specific to writing OpenSocial apps.
These. requesting the Viewer:
function getViewer(myCallback){
var req = opensocial. newDataRequest();
var id = opensocial. IdSpec.PersonId.VIEWER;
req.add(req.newFetchPersonRequest(id),