Transforming Json From Api Into An Activity Stream
Solution 1:
ActivityStream is just a specification for activities. Weather is just a model. A model can either be a subject/actor or an object that an actor acts upon to. In this case, weather can only be an object.
An example of activity that deals with weather is:
Martin checks the weather for London at 3:04 PM UTC on February 10, 2015.
The corresponding activity JSON is:
{"published":"2015-02-10T15:04:55Z","actor":{"url":"http://example.org/martin","objectType":"person","id":"tag:example.org,2011:martin","image":{"url":"http://example.org/martin/image","width":250,"height":250},"displayName":"Martin Smith"},"verb":"search","object":{"url":"http://api.openweathermap.org/data/2.5/weather?q=London","name":"London's weather","published":"2015-02-10T15:04:55Z"}}
Note that this is only an example. You may have different activities, depending on how you want to use the weather data.
Solution 2:
The activity stream concept is pretty simple. Here's a good example: "Wendy adds London to her list Places to visit"
In this case the actor is "wendy", the object is "london" the verb is "add" and the target is "places to visit".
You can use this syntax to support different use cases. I've seen people us it the activity stream spec for everything ranging from Leed certification of buildings, error reporting to social apps.
Example 2:
Application Uber broke down with error code 2 and has been assigned to John
- Actor: application:uber
- Verb: break
- Object: Error:2
- Target: user:John
Example 3:
RoadToVR published an article about Echo Arena
- Actor: RoadToVR
- Verb: published
- Object: Article:123
Advanced fields
The spec also outlines the TO field. You can use the TO field to support @mentions, hashtags and notifications.
Version 2
There is also a new version of the activity stream spec available: https://www.w3.org/TR/activitystreams-core/ So far I don't see any evidence of applications adopting this new spec.
Activity stream tutorial
This tutorial is a nice starting point if you want to build a Twitter style feed: https://getstream.io/get_started/
Post a Comment for "Transforming Json From Api Into An Activity Stream"