How can I best receive data from a web hook into Matlab?

14 visualizaciones (últimos 30 días)
There is website that can send text data via a webhook. I would like to process that data in Matlab. How can I best receive data from a webhook into Matlab?
Thank you VERY much.
BG

Respuesta aceptada

Walter Roberson
Walter Roberson el 12 de Abr. de 2021
The URL for the webhook could be connected to a webserver on your host that accepted the request (such as with PHP or ASP), constructed whatever data was needed, and invoked MATLAB (possibly through a the Automation Server API)
Or the URL for the webhook could be configure for a port that you have a MATLAB session directly listening on, such as by using tcpserver() https://www.mathworks.com/help/instrument/tcpserver.html with you handling the parsing and action in MATLAB. There is also a File Exchange contribution for handling TCP, UDP, and IP services.
  8 comentarios
Brian Greer
Brian Greer el 15 de Abr. de 2021
Understood.
I'm a beginner on TCP/IP , this is really valuable information. I'll work it. Thank you very much, greatly appreciate the help.
BG
Walter Roberson
Walter Roberson el 15 de Abr. de 2021
There are some protocols such as SMTP where it is normal for the server to reply with a greeting upon connection. It is not normal for HTTP though: for HTTP the client makes the connection and then immediately sends the command on the first line, and then sends optional headers on the second and following lines, ending with an empty line. The server then replies first with a header block, that might look something like
HTTP/1.1 200 OK
X-robots-tag: noindex,nofollow
Content-type: text/html; charset=UTF-8
Content-Length: 8595
Date: Thu, 15 Apr 2021 06:49:56 GMT
Server: Thanks For All The Fish Server
and then an empty line and then with HTML.
If you choose to implement directly in MATLAB, your code will be responsible for reading the command from the client, taking the appropriate action, and then replying with a header block, then an empty line, and then with an HTML block, and then closing the connection. As that can all be a bit of a nuisance, it is common to instead use a webserver program such as PHP or ASP. Or these days, probably python.

Iniciar sesión para comentar.

Más respuestas (0)

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by