Spark-Could-API-Events

De MCHobby - Wiki
Révision datée du 11 janvier 2015 à 15:55 par Admin (discussion | contributions) (Page créée avec « {{Spark.IO-Could-API-NAV}} {{traduction}} == Enregistrer un CallBack == {{bloc-etroit|text=In the build section of the Spark website, you will be able to register a URL on... »)
(diff) ← Version précédente | Voir la version actuelle (diff) | Version suivante → (diff)
Sauter à la navigation Sauter à la recherche


MCHobby investit du temps et de l'argent dans la réalisation de traduction et/ou documentation. C'est un travail long et fastidieux réalisé dans l'esprit Open-Source... donc gratuit et librement accessible.
SI vous aimez nos traductions et documentations ALORS aidez nous à en produire plus en achetant vos produits chez MCHobby.

Enregistrer un CallBack

In the build section of the Spark website, you will be able to register a URL on your own server to which we will POST each time one of your Spark Cores publishes a certain event.

Souscrire un événement

You can make an API call that will open a stream of Server-Sent Events (SSEs). You will make one API call that opens a connection to the Spark Cloud. That connection will stay open, unlike normal HTTP calls which end quickly. Very little data will come to you across the connection unless your Spark Core publishes an event, at which point you will be immediately notified.

To subscribe to an event stream, make a GET request to one of the following endpoints. This will open a Server-Sent Events (SSE) stream, i.e., a TCP socket that stays open. In each case, the event name filter in the URI is optional. When specifying an event name filter, published events will be limited to those events with names that begin with the specified string. For example, specifying an event name filter of 'temp' will return events with names 'temp' and 'temperature'.

SSE resources:

Subscribe to the firehose of public events, plus private events published by devices one owns:

GET /v1/events[/:event_name]

# EXAMPLE
curl -H "Authorization: Bearer 38bb7b318cc6898c80317decb34525844bc9db55"
https://api.spark.io/v1/events/temperature

Subscribe to all events, public and private, published by devices one owns:

GET /v1/devices/events[/:event_name]

# EXAMPLE
curl -H "Authorization: Bearer 38bb7b318cc6898c80317decb34525844bc9db55"
https://api.spark.io/v1/devices/events/temperature

Subscribe to events from one specific device. If the API user owns the device, then she will receive all events, public and private, published by that device. If the API user does not own the device she will only receive public events.

GET /v1/devices/:device_id/events[/:event_name]

# EXAMPLE
curl -H "Authorization: Bearer 38bb7b318cc6898c80317decb34525844bc9db55"
https://api.spark.io/v1/devices/55ff70064939494339432586/events/temperature

Source: Cloud CODE (API) créé par Spark.IO.

Traduction réalisée par Meurisse D pour MCHobby.be - Translated by Meurisse D. for MCHobby.be

Traduit avec l'autorisation de Spark.IO - Translated with the permission from Spark.IO - Spark.IO

Toute référence, mention ou extrait de cette traduction doit être explicitement accompagné du texte suivant : «  Traduction par MCHobby (www.MCHobby.be) - Vente de kit et composants » avec un lien vers la source (donc cette page) et ce quelque soit le média utilisé.

L'utilisation commercial de la traduction (texte) et/ou réalisation, même partielle, pourrait être soumis à redevance. Dans tous les cas de figures, vous devez également obtenir l'accord du(des) détenteur initial des droits. Celui de MC Hobby s'arrêtant au travail de traduction proprement dit.