How To - Collect Messages

From The Socknet

(Redirected from Message Collection)
Jump to: navigation, search

When a provider is prepared to collect a message it must contact the message's host. This requirement, as opposed to a system in which entire messages are forwarded, protects the accuracy of the message.

Contents

The Specification

Collecting from friends and fully-integrated services

Collecting from a user or a fully-integrated service is done by calling the get_message function on the user or service and including the id in the request.

Collecting from non-integrated or partially-integrated services

Collecting from a non-integrated or partially-integrated service is done by calling the URL given in the guid.

The result is treated differently depending on whether it is JSON.

JSON Formatted Service Messages

The result of a call to the guid URL is preferably in JSON.

Example:

HTTP GET http://service.com/messages/UserA/20395

->
{ message: "David posted a <a href=...>photo</a>.",
  created: ... HTTP Date ...
  edited: ... HTTP Date ...
}

If the response is has the same fields as a response from get_message it may be treated as a response from get_message.

Other Service Message Formats

If a call to a guid URL returns an HTTP Content-type other than "application/json" (or the JSON doesn't contain fields from this specification), then it is not Socknet data and has different rules.

If the content is HTML, then it may contain a link element containing an alternate guid URL that leads to a JSON formatted version. See Sharing.

If no alternative GUID is present or the content is not HTML, the message should be shown in a manner best fitting the Content-type. For example, if the content is an image or a music track, there are obvious ways to show it on a web page. If the content is a word processor document or spreadsheet, then a link is the best option, perhaps accompanied by a relevant icon.


Considerations

Any page that returns JSON is required by JSON standards to report the Content-type as application/json. It's a good idea to be strict about this. Help us all by requiring that developers follow this simple rule.

See Also

Personal tools