Basic information
Q: What version of OpenSocial do you support?
A: We support version 0.7 and 0.8.
opensocial.makeRequest
Q: Do I have to use port 80 to send requests back to
my server?
A: Yes. Only port 80 is available at the
moment, we are discussing opening a port in a higher range but that is not finalized.
Q: How do I validate that a makeRequest call actually
came from the particular viewer and owner identified in the request?
A: Send opensocial.ContentRequestParameters.AuthenticationType.SIGNED into your
makeRequest call. Doing so will cause OAUTH to digitally sign the request
and will allow you to verify the identity of the viewer and owner.
Q: What types of feeds do you support?
A: We currently support RSS2.
Common usage
Q: I’m new to all this, how do I do ... anything?
A: A great starter document was written to help you
get ramped up, find it here.
Q: How do I get all the photos for a particular album?
A: To do this, you'll need to send the following into the opt_param of a newFetchPhotosRequest:
opt_params[MyOpenSpace.DataRequest.PhotoRequestFields.ALBUM_ID]
= <some album id>;
Where <some album id> is the integer ID of an album you (probably) discovered from a newFetchAlbumsRequest call.
Q: I want to figure out what books the viewer likes,
how do I do that? What about additional data?
A: Use the code below to get the data you need (version 0.7):
var request = opensocial.newDataRequest();
var personFields = [opensocial.Person.Field.ID,MyOpenSpace.Person.Field.ABOUT,MyOpenSpace.Person.Field.BOOKS];
var param = {};
param[opensocial.DataRequest.PeopleRequestFields.PROFILE_DETAILS] = personFields;
var newReq = request.newFetchPersonRequest(opensocial.DataRequest.PersonId.VIEWER, param);
request.add(newReq);
request.send(callback);
For 0.8, the same code applies except replace the second line with this one:
var personFields = [opensocial.Person.Field.ID,opensocial.Person.Field.ABOUT_ME,opensocial.Person.Field.BOOKS];
And then in the callback (0.7):
response.get(opensocial.DataRequest.PersonId.VIEWER).getData().getField(MyOpenSpace.Person.Field.BOOKS);
For 0.8:
response.get(opensocial.IdSpec.PersonId.VIEWER).getData().getField(opensocial.Person.Field.BOOKS);
You can replace the fields inside personFields with any of those defined in MyOpenSpace.Person.Field or opensocial.Person.Field.
Q: Great! So I do the same thing to get extra data on viewer and owner friends right?
A: No, sorry, we don’t support that at this time.
Q: I want to access some of the extended entities, like videos, how do I do that?
A: For now, this will work similar to the code sample above, just replace newFetchPersonRequest with newFetchAlbumsRequest or newFetchVideoRequest, etc. However, very soon this won’t work, please see the code below for how to fetch video, album and photo data in the near future.
0.7:
var request = opensocial.newDataRequest();
var albumReq = MyOpenSpace.DataRequest.newFetchAlbumsRequest(opensocial.DataRequest.PersonId.VIEWER);
var photoReq = MyOpenSpace.DataRequest.newFetchPhotosRequest(opensocial.DataRequest.PersonId.VIEWER);
var videoReq = MyOpenSpace.DataRequest.newFetchVideosRequest(opensocial.DataRequest.PersonId.VIEWER);
request.add(albumReq);
request.add(photoReq);
request.add(videoReq);
request.send(callback);
For 0.8 replace opensocial.DataRequest.PersonId.VIEWER with opensocial.IdSpec.PersonId.VIEWER.
Flash
Q: What is loaded into my .swf and how is it loaded?
A: We currently use FlashVars to pass in the following parameters: opensocial_token, opensocial_surface and opensocial_consumer_key.
Miscellaneous
Q: Can the height of my application only be set from the Application Builder form? Is 1000px the maximum? Isn’t it dynamic? What about the width?
A: For now the width is static. As for the height, it can be adjusted dynamically with the following call:
gadgets.window.adjustHeight(opt_height);
This can't exceed 1000px on the home and profile views, but the maximum on the canvas is very large and can exceed 1000px. Leaving an empty opt_height will cause the iframe to attempt to resize itself based on the contents.
Q: How do I navigate between surfaces, and how do I pass data between surfaces?
A: To navigate between surfaces make this call:
gadgets.views.requestNavigateTo(surface, params);
Where "params" are some optional parameters that you can pass between surfaces. To collect the parameters on the other side of the call, you’ll do this:
gadgets.views.getParams();
Q: Do I have to store all my data on my servers using the makeRequest call? Isn’t there anything better?
A: Great question! There is indeed – our data store is up and running. You can save data for the current viewer with a key/value pair. Data can be retrieved for viewer, owner, viewer friends and owner friends. Use opensocial.DataRequest.newFetchPersonAppDataRequest and opensocial.DataRequest.newUpdatePersonAppDataRequest. More info on this can be found on the opensocial docs site.
newFetchPersonAppDataRequest
newUpdatePersonAppDataRequest