Welcome Developers!
MyOpenSpace.Widget Samples
What does this include? A number of bug fixes. A bootstrap loader to fix IE and Safari timing issues, and more:
The bootstrap call looks like this:
MyOpenSpace.Widgets.Bootstrapper.createWidget("MyOpenSpace.Widgets.FriendPicker", function(p){window.friendPicker = p;}, { element: "pickerDivID01", buildSelectedUI: true });
Make some noise if you find issues or have suggestions.
In reviewing the reactions of our user base to all the great apps being built by the community, we have been moved to give end users more configuration options in how they interact with apps. We have added a new privacy communication setting to users' profiles and slightly restricted how apps may send messages and comments. As originally deployed, an application could use the MySpace postTo extension to send messages to any user in the MySpace system, subject to that user's spam and privacy settings. To curtail abuse (occassionally a spammy app makes it thru the review gauntlet) we have tightened this up so that apps may only send messages to a viewer's friends.
Additionally, users may now disable communications from all apps (Edit Profile > Account Settings > Applications > Application Communication Settings). If an app attempts to send a message/comment to a user who has indicated they do not want communication from apps, upon confirmation of the postTo message the app viewer sees an error dialog "Undeliverable Message or Comment" and if a callback handler is attached it will receive an error response.
Update 4:30pm, Mon April 28: We have discovered a miss-behaving process (handling url-rewriting, of all things!) and are in the process of rolling out a fix.
Update 11:00am, Tue April 29: A patch went out last night which reduced a significant amount of the timeouts.
Soon we are enabling both server-side and client-side caching of the app surface content. This helps performance and creates a better user experience with those who have multiple apps installed on their profiles. Here is a quick break-down of how each type of user will be affected:
MySpace Admins & Developers will be able to:
NOTE: Caching will not be used for these users.
All Other Users (Including Friends of Apps) will:
NOTE: Caching will be enabled for these users.
Cache time will be for one hour initially but is configurable by the team here at MySpace and all users will be able to invalidate the cache with an explicit refresh.
NOTE: The only group really affected by this change, is developers who use friends of an app to test the app, while the app is private or in development. We do have support for multiple developers coming very soon, which is intended to replace the need to use friends of an app to test while an app is private. In the meantime, private apps will only be viewable by the developer or someone with administrative rights over the application. All other users will be treated as standard users.
In the spirit of making your lives easier, we are introducing... drum roll please...The MyOpenSocial.Widgets library.
You may be familiar with FriendPicker from the original PostTo sample application. Now, instead of filling your app up with tons of code cruft you can make a few simple calls for the same functionality:
//at top of fileMyOpenSpace.ClientLibraries.includeScript( MyOpenSpace.ClientLibraries.Scripts.MYSPACE_WIDGETS);...//later in a registered initvar myFriendPicker = new MyOpenSpace.Widgets.FriendPicker( { element: "pickerDiv01", buildSelectedUI: true });...//and when you want to see what you havevar pickedPerson = myFriendPicker.selectedFriend;
http://www.myspace.com/myopensapcewidgetsamples
This is early in development, so if you find issues leave comments here or in the forums. Also, check back in to this app periodically for new widgets as we release them.
Hello all, we rolled a few additions and updates this morning - here is a summary.
We’ve added some lightweight calls so you don’t have to get huge extended person objects.
Note: id can be owner or viewer and the opt_params parameter is currently not used.
[edit: proper way to access]
MyOpenSpace.DataRequest.newFetchIndicatorsRequest(id, opt_params)
Note: The enums that are currently used to access the results may change, but we'll give ample notice before any change is made and will remain backwards compatible for a time before removal. example: MyOpenSpace.Group.VIEWER_STATUS
We made a few bug fixes and added callback functionality
Thanks Chris!!!
<script type='text/javascript'>
var osContainer;
var dataReqObj;
var param;
function init(optResponse) {
osContainer = opensocial.Container.get();
param = {};
}
function getIndicator(stuff){
if (typeof(stuff) === 'undefined'){
dataReqObj = osContainer.newDataRequest();
dataReqObj.add(MyOpenSpace.DataRequest.newFetchIndicatorsRequest(opensocial.DataRequest.PersonId.VIEWER, param));
dataReqObj.send(getIndicator);
} else {
var result = stuff.get(MyOpenSpace.Group.VIEWER_INDICATORS).getData();
dumpProps(result);
function getMood(stuff) {
dataReqObj.add(MyOpenSpace.DataRequest.newFetchPersonMoodRequest(opensocial.DataRequest.PersonId.VIEWER, param));
dataReqObj.send(getMood);
var result = stuff.get(MyOpenSpace.Group.VIEWER_MOOD).getData();
function getStatus(stuff) {
dataReqObj.add(MyOpenSpace.DataRequest.newFetchPersonStatusRequest(opensocial.DataRequest.PersonId.VIEWER, param));
dataReqObj.send(getStatus);
var result = stuff.get(MyOpenSpace.Group.VIEWER_STATUS).getData();
function dumpProps(obj, parent) {
for (var i in obj) {
if (parent) { var msg = parent + "." + i + "\n" + obj[i]; } else { var msg = i + "\n" + obj[i]; }
if (!confirm(msg)) { return; }
if (typeof obj[i] == "object") {
if (parent) { dumpProps(obj[i], parent + "." + i); } else { dumpProps(obj[i], i); }
function postBlogCallback(){
var os_token = MyOpenSpace.MySpaceContainer.OSToken;
var message = opensocial.newMessage("I am a blog post");
message.setField(opensocial.Message.Field.TITLE, "About Testing");
message.setField(opensocial.Message.Field.TYPE, MyOpenSpace.PostTo.Targets.BLOG);
osContainer.postTo(os_token, message, null, ptCallback);
function ptCallback(someVal){
if (someVal == MyOpenSpace.PostTo.Result.ERROR) {
alert('callback gave error')
else if (someVal == MyOpenSpace.PostTo.Result.CANCELLED) {
alert('user cancelled PostTo')
else if (someVal == MyOpenSpace.PostTo.Result.SUCCESS) {
alert('WE ARE MEETING WITH GREAT SUCCESS!!!')
else {
alert('Unrecognized response: ' + someVal)
init();
</script>
<h1>Indicator, Mood, Status</h1>
<hr noshade >
<input type="button" onclick="getIndicator()" value="Show Owner Indicator" />
<input type="button" onclick="getMood()" value="Show Owner Mood" />
<input type="button" onclick="getStatus()" value="Show Owner Status" />
<div id="selectInsert"></div>
<h1>Post To: Call Me Back</h1>
<button onclick="postBlogCallback()">Blog post with callback</button>
Notable Updates from Last Push
Browser Aware Resizing <button onclick="gadgets.window.adjustHeight();"> </button> <button onclick="gadgets.window.adjustHeight(0.2);">0.2</button> <button onclick="gadgets.window.adjustHeight(0.5);">0.5</button> <button onclick="gadgets.window.adjustHeight(0.8);">0.8</button> <button onclick="gadgets.window.adjustHeight(1);">1.0</button> <button onclick="gadgets.window.adjustHeight(200);">200</button> <button onclick="gadgets.window.adjustHeight(800);">800</button> What they do in order:1. Adjust height to content2. Make height 20% of viewable space3. Make height 50% of viewable space4. Make height 80% of viewable space5. Make height 100% of viewable space6. Make height = 200px7. Make height = 800px
Delete App DataYou can now delete app data.User Type in Person You can now determine what a friend's user type is. Some examples are Band and Regular userfriend.getField(MyOpenSpace.Person.Field.USER_TYPE);
PostTo and Flash
We released a fix for the flash issue in PostTo
Also check out Chad's post regarding encoding urls
Hello everybody, this is a request to everyone out there using the makeRequest function.
Inside the container we are encoding all URLs and post parameters, so please don't encode them yourselves. This will result in a double encode which will get mangled by the proxy.
If you have noticed an issue with your makeRequest function, this may be the cause.
Good:
gadgets.io.makeRequest("http://myurl.com?p=yay");
Bad (for two reasons!):
opensocial.makeRequest(encodeUriComponent("http://myurl.com?p=yay"));
The second one is bad because it: a) encodes the URL and b) uses the deprecated opensocial.makeRequest call, which is specific to OpenSocial 0.6, please update your code to be 0.7 friendly!
Thanks,
Chad
I know a few of you are using the non-MDP version of PostTo found here: http://www.myspace.com/posttomyspace - I was just made aware that some issues arose today and it was just disabled until they can be addressed (which could take more than a day).They have a forum here: posttomyspace if you have questions for the team.The MDP version is still available - please find information about it here: http://developer.myspace.com/Community/blogs/mdpjavascriptcontainer/archive/2008/04/10/introducing-post-to.aspx
Hate to be the bearer of bad news – don’t kill the messenger!
DM
In a nutshell, Post To enables you to provide your application users the ability to post things to MySpace. In our initial launch we’ll be offering the following Post To targets:
- Posting to the viewers profile- Posting a bulletin- Posting to the viewers blog- Adding a comment- Sending a message
Each of the targets can accept different levels of text and markup. For instance, some will accept HTML while others don’t and this is sometimes controlled by the end users privacy settings. Because of this we recommend thoroughly testing your applications.
This should go without saying but, SPAM will not be tolerated!
Overview
Post To is one of our first features that will enable you to not only help your users communicate with friends but also to start virally spreading news of your application. With just a few lines of code you can start pushing content to your users profile and friends.
Post To works by allowing you to pass a few parameters to a JavaScript function that then displays an overlay over your application (see screenshots below) . The user can then perform different actions based on the target invoked and then submit or cancel the action.
Finally, Post To is currently only available on Canvas pages.
Invoking Post To
Below we’ll go through the basics of using Post To starting with a working out of the box code example. For information on things not covered please see the http://developer.myspace.com/community/myspace/referenceIntro.aspx
Sample Code
var os_token = MyOpenSpace.MySpaceContainer.OSToken;var osContainer = opensocial.Container.get();
// gets all supported post to targetsvar supported = osContainer.getMySpaceEnvironment().getSupportedPostToTargets();var recipientPerson;
// need a person object for add comment and send message
function init() {
dataReqObj.add(osContainer.newFetchPersonRequest(opensocial.DataRequest.PersonId.OWNER));
dataReqObj.send(ownerResponse);
function ownerResponse(data) {
recipientPerson = data.get(opensocial.DataRequest.PersonId.OWNER).getData();
loadSupportedTargets();
function loadSupportedTargets() {
var temp = "<select id=\"supportedTargets\">";
for (var i = 0; i < supported.length; i++)
{
temp += "<option value=\"" + supported[ i ] + "\">" + supported[ i ] + "</option>";
temp += "</select>";
document.getElementById("selectInsert").innerHTML = temp;
function invokePostTo(){
var target_is_supported = false;
var target = document.getElementById("supportedTargets").options[document.getElementById("supportedTargets").selectedIndex].value;
var subject = "subject text";
var content = "content text";
// make sure that the selected target is enabled
for (var i = 0; i < supported.length; i++) {
if (supported[ i ] === target) {
target_is_supported = true;
break;
if (target_is_supported) {
// create a new message object passing in the content to be posted and then set the subject and target fields
var message = opensocial.newMessage(content);
message.setField(opensocial.Message.Field.TITLE, subject);
message.setField(opensocial.Message.Field.TYPE, target);
// show post to
osContainer.postTo(os_token, message, recipientPerson);
<br>
<input type="button" onclick="invokePostTo()" value="invoke" />
postTo
opensocial.Container.get().postTo(os_token, message, opt_person, opt_callback);
openSocial.Message
Below is the function for creating a new opensocial.Message object:
var message = opensocial.newMessage(body, opt_params);
The Post To opensocial.Message message allows for three fields:
1. opensocial.Message.Field.TYPE
A supported PostTo target type from MyOpenSpace.PostTo.Targets enum. You can check if a particular target is supported by invoking: opensocial.Container.get().getMySpaceEnvironment().getSupportedPostToTargets()Currently supported targets:- MyOpenSpace.PostTo.Targets.PROFILE- MyOpenSpace.PostTo.Targets.SEND_MESSAGE- MyOpenSpace.PostTo.Targets.COMMENTS- MyOpenSpace.PostTo.Targets.BULLETINS- MyOpenSpace.PostTo.Targets.BLOG
Example: message.setField(opensocial.Message.Field.Type, MyOpenSpace.PostTo.Targets.PROFILE);2. opensocial.Message.Field.TITLE
A title for the post – this is not used in every target
Example:
message.setField(opensocial.Message.Field.TITLE, “Hello World”);3. opensocial.Message.Field.BODY
The content you want to post.
message.setField(opensocial.Message.Field.BODY, “Hello World”);
Note: Body can also be passed in the constructor.
Target Screen Shots
Below are screen shots of the various targets with links on where you can find the corresponding MySpace feature
Posting to ProfilePosting to the users profile copies functionality found here: http://profileedit.myspace.com/index.cfm?fuseaction=profile.interests
Posting to Bulletin
Posting a bulletin copies functionality found here: http://bulletins.myspace.com/index.cfm?fuseaction=bulletin.edit
Posting to Blog
Making a blog post copies functionality found here: http://blog.myspace.com/index.cfm?fuseaction=blog.create&editor=true
Posting a Comment
Posting a comment copies functionality found here: http://comment.myspace.com/index.cfm?fuseaction=user.viewProfile_commentForm&friendID=20599042
Sending a Message
Sending a message copies functionality found here: http://messaging.myspace.com/index.cfm?fuseaction=mail.message&friendID=20599042
Sample Application
Chris has created a handy sample application for you to see Post To in action. You can install it here: http://profile.myspace.com/index.cfm?fuseaction=user.viewprofile&friendid=364361327
Last week we announced that we’ll be supporting developers with approved MySpace applications in their press release efforts in an organized way to provide our developers with the best possible visibility and not flood the media. We’re getting great responses and are excited to work with all of you! We’re especially impressed by the creativity and innovation that we are seeing and feel lucky that some of the best developers out there are using MySpace to launch their applications!
Again, if you’d like to be considered for this program and/or are interested in developing and distributing a joint MySpace/[Your Application or company] press release, please drop us an email at myspace@sparkpr.com.
Hi everyone-
For those who haven't been following my personal blog, I'm in Australia for the next few days where we will be presenting MDP and all its' goodness down under.
Later this week, I'll be presenting in Beijing, followed up by Seoul before returning to Seattle.
If you want to see pics of my travels and some of the folks behind MDP, you can check out my personal blog (www.myspace.com/signalloss).
I'll see if I can get some of the press releases and articles from these events and post them up. Stay tuned!
Cheers,
Max Newbould
Greetings Developers!
For those who haven't run into me online or at the DevJams, I'm Max Newbould, the product owner/lead developer for the MySpace OpenSocial container.
We are always hard at work and try to make it into IRC and the forums as much as possible, and want to make sure no useful information is only disseminated on a single medium.
Forthcoming bits (I don't like to give dates but I will post when they are live)
Global AppData Store - you will soon be able to create fetch/update PersonAppDataRequests with an idSpec of MyOpenSpace.Group.GLOBAL_APP_DATA to store key value pairs accessible to all instances of your application.
Client Lib Selection - as you may have already read, we are removing prototype 1.5.1.1 as an implicit include on the container. You can still reference it as detailed here: http://developer.myspace.com/Community/forums/t/1330.aspx. This was done to ween applications off prototype without explicit inclusion, as the new client JS toolkit selection functionality is coming.
PostTo - the ability to post to different MySpace areas from inside an application; messages, comments, profiles, bulletins, etc. This is a huge feature and defined as an extension.
Setting the record straight on AppData
We had been getting bug reports regarding either getting stale versions from cache, or an update not being honored when a fetch was sent in the same request.
Behind the scenes, MySpace has a highly asynchronous nature to meet our scaling requirements. An update will persist to databases after being sent, but we cannot guarantee the timing of when that happens. We're talking 300ms - 3s (3s during peak times/issues), but we need developers to understand this limitation and work with it. It's perfectly fine to send an update and use the local copy of the key value pair until a new fetch is absolutely required.
As always, we love to hear from people using our container and make a huge effort to keep everyone in the loop.
Thanks much,
Max