I work as a web designer at a small startup and I've been tasked with creating a PHP program/file that will receive JSON data from our app's backend server whenever a new user signs up for the app or does a number of other events, process the data and send it to our CRM (Insightly).
I have a fairly good understanding of PHP when it comes to designing websites, but I've never really used it to process data like this. My original idea was to set up a .json file on our Azure server for each event and have the backend write the data to one of these files. The data is coming as POST data (not from a form) and I was using php://input to collect the data and write it to the .json files. The Azure server would then periodically run my PHP program to check if there's data in the file, and send the data to Insightly if there is.
However, the developer I'm working with wants to receive a new Contact ID/Project ID/etc that Insightly generates as an HTTP response immediately. So basically:
- backend server sends json data either to .json file or PHP script on server
- PHP script either immediately reads .json file or just json_decodes the data into an array to send to Insightly
- Insightly creates a new project/contact/organization and returns ID that it creates to PHP script
- PHP script sends back that ID as an HTTP response to the backend
So my questions are how can I have PHP "listen" to the .json files to immediately run the Insightly operations and/or how can I send back an HTTP response to the backend server once the Insightly update is complete? Really, what's the best way to be going about this? Any advice or suggestions help.