Skip to content
ciberch edited this page Sep 20, 2012 · 6 revisions

Authentication

GET /auth/:provider

  • Starts the auth flow for the SSO provider: facebook, twitter or github
  • This allows users to authenticate using 3-legged OAuth. It requires interaction with the user agent. For mobile device access see the Impersonation doc.

GET /logout

Logs the user out

Authenticated Endpoints

POST /activities

Allows the user to create a new activity. Note that the current user will be set as the actor

Remember to pass the appropriate Content-Type: application/json

Here is an example of the POST body(In JSON)

Request

{
  "streams":["general"],
  "object":{
    "thumbnail":{
      "height":65.01818181818182,
      "width":60,
      "url":"http://moni-air.local:8080/photos/55e95a85-f584-debe-1f8a-a142def78194/twitter-stream-xs.png"
    },
    "fullImage":{
      "height":596,
      "width":550,
      "url":"http://moni-air.local:8080/photos/a3176997-fa8e-442d-fcb3-be03f9fd3529/twitter-stream.png"
    },
    "image":{
      "height":277.4109090909091,
      "width":256,
      "url":"http://moni-air.local:8080/photos/f31a8fd7-b5e3-646f-f3a3-be14b4e97539/twitter-stream-sm.png"
    },
    "title":"twitter-stream.png",
    "displayName":"twitter-stream.png",
    "url":"http://moni-air.local:8080/photos/a3176997-fa8e-442d-fcb3-be03f9fd3529/twitter-stream.png",
    "objectType":"photo"
  },
  "icon":null,
  "verb":"post"
}

Response

Status Code: 201 Created

POST /photos

Allows the user to upload a photo. Resizes the photos in 2 additional images.

Request

This must be a multiform post with a parameter names image which contains the image file.

Response

The activity syndicated to the personal stream

{
  "title":"posted a photo", "_id":"505b384cfc91900000000017",
  "streams":["personal"],
  "generator":null,
  "provider":null,
  "updated":"2012-09-20T15:37:48.845Z",
  "published":"2012-09-20T15:37:48.845Z",
  "target":null,
  "actor":{
    "image":{
      "url":"https://fbcdn-profile-a.akamaihd.net/hprofile-ak-ash3/623754_608201527_1487122574_q.jpg"
    },
    "icon":null,
    "published":"2012-09-20T02:05:05.450Z",
    "objectType":"person",
    "updated":"2012-09-20T02:05:05.450Z",
    "displayName":"Monica Wilkinson",
    "author":"505a79cb461e560000000004",
    "_id":"505a79d1461e560000000007",
    "__v":4
  },
  "object":{
    "thumbnail":{
      "height":65.01818181818182,
      "width":60,
      "url":"http://asms.cloudfoundry.com/photos/55e95a85-f584-debe-1f8a-a142def78194/twitter-stream-xs.png"
    },
    "fullImage":{
      "height":596,
      "width":550,
      "url":"http://asms.cloudfoundry.com/photos/a3176997-fa8e-442d-fcb3-be03f9fd3529/twitter-stream.png"
    },
    "image":{
      "height":277.4109090909091,
      "width":256,
      "url":"http://asms.cloudfoundry.com/photos/f31a8fd7-b5e3-646f-f3a3-be14b4e97539/twitter-stream-sm.png"
    },
    "title":"twitter-stream.png",
    "displayName":"twitter-stream.png",
    "url":"http://asms.cloudfoundry.com/photos/a3176997-fa8e-442d-fcb3-be03f9fd3529/twitter-stream.png",
    "objectType":"photo"
  },
  "icon":null,
  "verb":"post"
}

GET /photos -- TODO

Returns the list of photos the current user has uploaded in JSON array. Each photo is represented as an activity object in Activity Streams.

GET /

Returns the activities and settings for the default stream general

Params

  • ?json=true : If set will return the output in json regardless of content headers
  • verb : Pass one or more verbs to include in the stream. Example: verb=post&verb=like&verb=start&objectType=none
  • objectType: Pass one or more object types to include in the stream. Example: objectType=application&objectType=article&objectType=person&objectType=place&objectType=comment
  • actorObjectType : Pass one or more actor types to include in the stream. Example: actorObjectType=person

Response

{
  "layout":"layout",
  "currentUser":{
  "author":"505a73af1de6fb311a000003",
  "url":"http://asms.cloudfoundry.com/users/505b39e3607393435a000007",
  "displayName":"Monica Wilkinson",
  "_id":"505b39e3607393435a000007",
  "__v":0,
  "updated":"2012-09-20T15:44:35.652Z",
  "objectType":"person",
  "published":"2012-09-20T15:44:35.652Z",
  "icon":null,
  "image":{
    "url":"http://1.gravatar.com/avatar/56a8ab4459cdff419bd0faf65c011f0f?s=48"
  }
},
  "streams":{
    "general":{
      "name":"general",
      "items":[
        {
          "url":"",
          "title":"posted a new comment",
          "content":"",
          "inReplyTo":"505a73c91de6fb311a000013",
          "_id":"505a73d91de6fb311a000015",
          "__v":0,
          "streams":["general"],
          "generator":null,
          "provider":{
            "image":null,
            "icon":{
              "url":"http://www.cloudfoundry.com/images/favicon.ico"
            },
            "published":null,
            "updated":null,
            "fullImage":null,
            "thumbnail":null,
            "attachments":[],
            "upstreamDuplicates":[],
            "downstreamDuplicates":[],
            "_id":"505a73af1de6fb311a000002",
            "displayName":"Cloud Foundry",
            "objectType":"Service",
            "__v":0
          },
          "updated":"2012-09-20T01:39:37.597Z",
          "published":"2012-09-20T01:39:37.597Z",
          "target":null,
          "actor":{
            "author":"505a73af1de6fb311a000005",
            "url":"http://asms.cloudfoundry.com/users/505a73c4559da15c54000007",
            "displayName":"Monica Wilkinson",
            "_id":"505a73c4559da15c54000007",
            "__v":0,
            "location":{
              "position":{
                "latitude":34.075755,
                "longitude":-118.393416
              }
            },
            "updated":"2012-09-20T01:39:16.051Z",
            "objectType":"person",
            "published":"2012-09-20T01:39:16.051Z",
            "icon":null,
            "image":{
              "url":"http://a0.twimg.com/profile_images/2485910656/d01zhn184wvix6jnp1oz_normal.jpeg"
            }
          },
          "object":{
            "objectType":"comment",
            "content":"Changed default stream name"
          },
          "icon":null,
          "verb":"post"
        },
        {
          "url":"",
          "title":"liked a new photo",
          "content":"",
          "inReplyTo":"505a73c91de6fb311a000013",
          "_id":"505a73cb1de6fb311a000014",
          "__v":0,
          "streams":["general"],
          "generator":null,
          "provider":{
            "image":null,
            "icon":{
              "url":"http://www.cloudfoundry.com/images/favicon.ico"
            },
            "published":null,
            "updated":null,
            "fullImage":null,
            "thumbnail":null,
            "attachments":[],
            "upstreamDuplicates":[],
            "downstreamDuplicates":[],
            "_id":"505a73af1de6fb311a000002",
            "displayName":"Cloud Foundry",
            "objectType":"Service",
            "__v":0
          },
          "updated":"2012-09-20T01:39:23.861Z",
          "published":"2012-09-20T01:39:23.861Z",
          "target":null,
          "actor":{
            "author":"505a73af1de6fb311a000005",
            "url":"http://asms.cloudfoundry.com/users/505a73c4559da15c54000007",
            "displayName":"Monica Wilkinson",
            "_id":"505a73c4559da15c54000007",
            "__v":0,
            "location":{
              "position":{
                "latitude":34.075755,
                "longitude":-118.393416
              }
            },
            "updated":"2012-09-20T01:39:16.051Z",
            "objectType":"person",
            "published":"2012-09-20T01:39:16.051Z",
            "icon":null,
            "image":{
              "url":"http://a0.twimg.com/profile_images/2485910656/d01zhn184wvix6jnp1oz_normal.jpeg"
            }
          },
          "object":{
            "objectType":"photo",
            "url":"http://asms.cloudfoundry.com/photos/d42a4122-e7af-3966-f109-29987b594929/github-round.png",
            "displayName":"github-round.png",
            "title":"github-round.png",
            "image":{
              "url":"http://asms.cloudfoundry.com/photos/0bc750be-6cac-a5d9-ce65-e138fe8d1368/github-round-sm.png",
              "width":256,
              "height":256
            },
            "fullImage":{
              "url":"http://asms.cloudfoundry.com/photos/d42a4122-e7af-3966-f109-29987b594929/github-round.png",
              "width":512,
              "height":512
            },
            "thumbnail":{
              "url":"http://asms.cloudfoundry.com/photos/6db88a00-1275-1ae8-a713-c17b3a98cd42/github-round-xs.png",
              "width":60,
              "height":60
            }
          },
          "icon":null,
          "verb":"like"
        },
        {
          "url":"",
          "title":"posted a new photo",
          "content":"",
          "inReplyTo":null,
          "_id":"505a73c91de6fb311a000013",
          "__v":0,
          "streams":["general"],
          "generator":null,
          "provider":{
            "image":null,
            "icon":{
              "url":"http://www.cloudfoundry.com/images/favicon.ico"
            },
            "published":null,
            "updated":null,
            "fullImage":null,
            "thumbnail":null,
            "attachments":[],
            "upstreamDuplicates":[],
            "downstreamDuplicates":[],
            "_id":"505a73af1de6fb311a000002",
            "displayName":"Cloud Foundry",
            "objectType":"Service",
            "__v":0
          },
          "updated":"2012-09-20T01:39:21.872Z",
          "published":"2012-09-20T01:39:21.872Z",
          "target":null,
          "actor":{
            "author":"505a73af1de6fb311a000005",
            "url":"http://asms.cloudfoundry.com/users/505a73c4559da15c54000007",
            "displayName":"Monica Wilkinson",
            "_id":"505a73c4559da15c54000007",
            "__v":0,
            "location":{
              "position":{
                "latitude":34.075755,
                "longitude":-118.393416
              }
            },
            "updated":"2012-09-20T01:39:16.051Z",
            "objectType":"person",
            "published":"2012-09-20T01:39:16.051Z",
            "icon":null,
            "image":{
              "url":"http://a0.twimg.com/profile_images/2485910656/d01zhn184wvix6jnp1oz_normal.jpeg"
            }
          },
          "object":{
            "thumbnail":{
              "height":60,
              "width":60,
              "url":"http://asms.cloudfoundry.com/photos/6db88a00-1275-1ae8-a713-c17b3a98cd42/github-round-xs.png"
            },
            "fullImage":{
              "height":512,
              "width":512,
              "url":"http://asms.cloudfoundry.com/photos/d42a4122-e7af-3966-f109-29987b594929/github-round.png"
            },
            "image":{
              "height":256,
              "width":256,
              "url":"http://asms.cloudfoundry.com/photos/0bc750be-6cac-a5d9-ce65-e138fe8d1368/github-round-sm.png"
            },
            "title":"github-round.png",
            "displayName":"github-round.png",
            "url":"http://asms.cloudfoundry.com/photos/d42a4122-e7af-3966-f109-29987b594929/github-round.png",
            "objectType":"photo"
          },
          "icon":null,
          "verb":"post"
        }
      ]
    },
    "logos":{
      "name":"logos",
      "items":[]
    }
  },
  "desiredStream":"general",
  "included":{
    "verbs":["post", "like"],
    "objectTypes":["none", "photo", "application", "article", "person", "place", "service", "instance", "comment"],
    "actorObjectTypes":["none", "person"]
  },
  "metadata":{
    "actorTypes":["Person", "Group", "Application", "Service"],
    "objectTypes":["Photo", "Application", "Instance", "Article", "Person", "Place", "Service", "Comment"],
    "verbs":["Post", "Favorite", "Follow", "Join", "Like", "Friend", "Play", "Save", "Share", "Tag", "Create", "Update", "Read", "Delete", "Check In", "Like"]
  },
  "filters":{
  "usedVerbs":["start", "post", "like"],
  "usedObjects":["App Instance 0 at http://172.30.49.86:24167", "App Instance 1 at http://172.30.50.5:14650", "github-round.png", "App Instance 0", "App Instance 1"],
  "usedObjectTypes":["instance", "photo", "comment"],
  "usedActorObjectTypes":["person"],
  "usedActors":["Monica Wilkinson"]
}}

GET /streams/[stream name]

Same functionality as above but you can pass the stream name that you want to fetch.

Params

  • ?json=true : If set will return the output in json regardless of content headers
  • verb : Pass one or more verbs to include in the stream. Example: verb=post&verb=like&verb=start&objectType=none
  • objectType: Pass one or more object types to include in the stream. Example: objectType=application&objectType=article&objectType=person&objectType=place&objectType=comment
  • actorObjectType : Pass one or more actor types to include in the stream. Example: actorObjectType=person

XHR Methods

Offered via Socket.io polling Sample polling request is: GET /socket.io/1/xhr-polling/11276406391786944637?t=1346272433574

Once the Socket.io polling is happening you can send messages to the server

We currently support one type of message:

create-activity

Backbone.sync = function(method, model, options) {
        if (model.url === "/activities") {
            if (method === "create") {
                var act = model.toJSON();
                    console.dir(act);
                    delete(act.likes);
                    delete(act.comments);
                    App.socketIoClient.emit("create-activity", act);
                    return true;
            } 
        }
        return defaultSync(method, model, options);
    }

Create Activity can be used for:

  • New Activities
  • In Reply To Activities
    • Likes
    • Comments