Webhooks Receiver - any hints on how to build one in Livecode?

Bringing the internet highway into your project? Building FTP, HTTP, email, chat or other client solutions?

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
aetaylorBUSBnWt
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 118
Joined: Thu Sep 20, 2012 5:11 pm

Webhooks Receiver - any hints on how to build one in Livecode?

Post by aetaylorBUSBnWt » Wed Sep 28, 2022 11:41 pm

Hi,

I am working on an App that needs to integrate with a Camera system where the vendor can send me data via a Webhooks Receiver.
They say it is easy and just go search on Google for how to do such.

I thought I might check to see if there is built in support in Livecode or somebody who has done this and willing to share some code about how to build such in Livecode.

Thanks,
Andrew

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9802
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: Webhooks Receiver - any hints on how to build one in Livecode?

Post by FourthWorld » Thu Sep 29, 2022 1:28 am

Is this app to be run on a server? AFAIK webhooks require a persistent listener.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

aetaylorBUSBnWt
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 118
Joined: Thu Sep 20, 2012 5:11 pm

Re: Webhooks Receiver - any hints on how to build one in Livecode?

Post by aetaylorBUSBnWt » Thu Sep 29, 2022 2:44 pm

I had nor really thought about it, but yes the program would be running constantly on the machine it is on.

The machine would not be technically a server, but it would be constantly on.

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9802
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: Webhooks Receiver - any hints on how to build one in Livecode?

Post by FourthWorld » Thu Sep 29, 2022 6:35 pm

aetaylorBUSBnWt wrote:
Thu Sep 29, 2022 2:44 pm
The machine would not be technically a server, but it would be constantly on.
That's the first step. As I understand it the receiver will need to open a port for listening, and have an HTTPS server process running to receive the hook message on that port. So it effectively becomes a server.

To be reachable at the URL provided to the hook service, the server will need a fixed IP (or DynDNS, but that has its own concerns). And since most hooks use SSL it'll need a cert, which will usually need an assigned domain name (can be a subdomain; most of my server services are on subdomains 'cause they're easy and cheap to set up).

And of course if the machine running this app is inside your firewall, this will likely require setting up port forwarding on the local router, so the hook request will be allowed to reach the server.

You can write an httpd server in LC, and the one they provide for testing mobile apps may make a good starting point.

But no need to reinvent that wheel. Apache, Lighttp, NginX and other packages are free, open source, and purpose-built for that. Each of those includes mechanisms for launching custom programs to pass request handling to; Apache and Lighttpd support CGI, and NginX provides socket comms to persistent processes. There may even be webhook add-on packages for those servers to simplify some aspects of implementation.

If all that setup is impractical in the local client, you could consider having the hook handling on an external server, with the local app polling your server periodically for new data. That obviates the push benefit of hooks, of course, but at least it keeps the local app simple to install and maintain.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

Post Reply

Return to “Internet”