Add JSON message from web-hook to MySQL

I publish data from Electron as JSON into particle cloud and I want to set up a web-hook which forwards the JSON to my web server with MySQL where

  • JSON is parsed if needed
  • key: value pairs are added to MySQL db

How can I do it? For example, do I need a server side script (eg php) which gets POST message from web-hook, parses the JSON and adds it to MySQL or there is a way to directly post JSON from particle web-hook to MySQL on my server? I have no hands-on experience with such issues so I may be not aware of some obvious things

This isn’t quite what you were asking for, but another option is to use a local node.js server to write to MySQL. No webhook required, and the server can be on a home network with NAT, dynamic IP address, and no firewall rules changes are required. Here’s a sample project for that:

Although @rickkas7 has provided you with a short-cut on the way to your solution, it’s usually well received by the community when you first search for potentially already existing topics that may address your need and if you really haven’t found anything state the fact.

As for the first part of that, this would be a selection of topics that come up with the search terms


https://community.particle.io/search?q=webhook%20mysql

Thanks ScruffR. My first attempt to search was probably with other less relevant key words. Found tons of relevant threads now and am on reading them.

1 Like

I can tell you how I do it. Photon publishes data; webhook forwards the data to a PHP script on my website; PHP script decodes the data, builds the MySQL INSERT statement and executes it. Data now resides in the table.

1 Like

Thanks Muskie. Could you share a template of your PHP script doing the job? Thanks