-
Notifications
You must be signed in to change notification settings - Fork 0
get_local_whispers
timojaask edited this page Jun 29, 2014
·
2 revisions
Get 50 latest messages from a given area.
-
URL:
http://whispr.outi.me/api/get_local_whispers - Method: Get
-
Arguments:
- min_lat: Minimum latitude of the message coordinate
- max_lat: Maximum latitude of the message coordinate
- min_long: Minimum longitude of the message coordinate
- max_long: Maximum longitude of the message coordinate
- json: If set to 1, the result will be returned as JSON object, otherwise as HTML table
- timestamp: Unix timestamp. If specified, only messages newer or same as the timestamp will be returned
- Return value: List of messages either as JSON or a HTML table
##C#
var client = new HttpClient();
// Define the area from which the messages are to be retrieved
// Note: WBoundingBox.FromRadius is a helper method found in Skene Windows Phone project
var area = WBoundingBox.FromRadius(location, radiusMeters);
var locationStr = string.Format("&min_lat={0}&min_long={1}&max_lat={2}&max_long={3}",
area.Min.Latitude.ToString(CultureInfo.InvariantCulture),
area.Min.Longitude.ToString(CultureInfo.InvariantCulture),
area.Max.Latitude.ToString(CultureInfo.InvariantCulture),
area.Max.Longitude.ToString(CultureInfo.InvariantCulture));
// Convert date and time of the last successful get request to Unix time stamp
// so that we only get messages that game after that time
var lastGetTimeStamp = Utils.DateTimeToUnixTimestamp(lastGet);
// Create the parameters string
var getParameters = string.Format("?json=1×tamp={0}", lastGetTimeStamp) + locationStr;
// Create the final URL
var uri = new Uri("http://whispr.outi.me/api/get_local_whispers" + getParameters);
// Send the request and get a result (JSON string)
var json = await client.GetStringAsync(uri);
// Deserialize the JSON string into a list of SkeneMessage objects
IEnumerable<Message> latestLocalMessages = JsonConvert.DeserializeObject<List<SkeneMessage>>(json);