...
Be aware that OpenSocial is planning to have IRI to identify resources.
0. security token
...
Security token should contain the context information. Now it contains OWNER and VIEWER.For spaces OWNER should be changed into CONTEXT, which would equal to a IRI for either space or personappId information, which helps a server to identify the running app.
1. osapi.
...
getContext (new)
osapi
...
.getContext
...
Gadget should be able to know whether it belongs to a space or to a person and their respective ids.
This API retrieves info about where widget lives
Code Block | ||||
---|---|---|---|---|
| ||||
osapi.context.get().execute(getContext(function(context){ context.id; // IRI id of the item context.service; // "people" or "spaces" context.object; // object that contains info about Space or Person }); |
2. osapi.people
osapi.people.getViewer
Get the user who looks at widget at the moment (Viewer)
Code Block | ||||
---|---|---|---|---|
| ||||
osapi.people.getViewer().execute(function(viewer){ viewer.id; viewer.displayName; }); |
osapi.people.
...
Get owner of the widget
(new) For spaces: if viewer is the space owner it returns this viewer, if not owner - it returns any other owner of a space
...
osapi.people.getOwner().execute(function(owner){
owner.id;
owner.displayName;
});
osapi.people.get
(new) Get a list of people (participants) members in a space with IRI = example.org/spaces/18
Code Block | ||||
---|---|---|---|---|
| ||||
osapi.people.get({iduserId: "http://example.org/spaces/18", groupId: "@self@members"}).execute(function(response){ response[0].displayName; }); |
Get space owners (or members)
Get a list of owners in a space.
Code Block | ||||
---|---|---|---|---|
| ||||
osapi.groups.get({id: "http://example.org/spaces/18"}).execute(function(groups){ // groups[0].id - owners = "ID49" // groups[1].id - members = "ID50" osapi.people.get({groupId: groups[0].id}).execute(function(owners){ owners[0].displayName; // owners of a space with idIRI = "http://example.org/space/18" }); }); |
...
osapi.spaces.get
(new) Get a list of spaces for a person or for a space
Code Block | ||||
---|---|---|---|---|
| ||||
osapi.spaces.get({idresourceId: "http://example.org/people/1john.doe"}).execute(function(response){ response[0].displayName; }); |
...
Code Block | ||||
---|---|---|---|---|
| ||||
osapi.apps.get({idresourceId: "http://example.org/space/18"}).execute(function(response){ response[0].displayName; }); |
...
Code Block | ||||
---|---|---|---|---|
| ||||
osapi.appdata.update({idresourceId: "http://example.org/spacespaces/1", data: {key: value}).execute(function(){ }); |
...
Code Block | ||||
---|---|---|---|---|
| ||||
osapi.appdata.get({idresourceId: "http://example.org/spacespaces/1", keys: ['key']).execute(function(data){ data['user1']['key']; }); |
...
Code Block | ||||
---|---|---|---|---|
| ||||
osapi.activitystreams.get({idresourceId: "http://example.org/spacespaces/1", count: 20}).execute(function(){ }); |
...
Code Block | ||||
---|---|---|---|---|
| ||||
osapi.albums.get({idresourceId: "http://example.org/spacespaces/1"}).execute(function(){ }); |
...
A Space can have many different groups. The groups can be created and deleted. Below is the a list of generic (container-independent) groups for a space:
...
Code Block | ||||
---|---|---|---|---|
| ||||
osapi.groups.get({idresourceId: "http://example.org/spacespaces/1"}).execute(function(results){ // results = [{id: "1", name: "members"},{id: "2", name: "owners"}] }); |
...