Score:1

How can I receive and process form data submitted from an external site?

fi flag

I'm working on a CRM implementation in Drupal for a client and they have an existing website with forms on for people to make enquiries and so on. They would like the data submitted via those forms to automatically become entities in the CRM.

I could replace the forms with webforms from the Drupal site but that would be clunky, as they would have to either be in iframes, or users would be taken to a separate site which would have to be styled the same and so on.

So ideally I would like to have their existing forms on the remote site POST the data to the Drupal server and then use that data to populate Drupal entities.

The only way that comes to mind is to have a PHP script on the server which processes the POST data and then bootstraps Drupal and creates the entity. But that seems somewhat clunky too. I'm wondering if there is a more Drupally way to do it.

Could Feeds be relevant I wonder? Could it be a custom feed type?

I'm interested in any ideas people have. Thanks!

Score:0
in flag

Feeds

If you want to consume external data and produce entities from those data, then Feeds is the way to go. This is it's primary use case. Feeds is also a mature and well-known module with many tutorial resources on the Internet. Here is one that I think is suitable to your needs: https://www.drupal.org/docs/contributed-modules/feeds/creating-and-editing-import-feeds

REST API

The one "gotcha" to this solution is that Feeds relies on pulling data. If, instead, you must originate the request on the remote server, then Feeds won't help. Instead, you'll need to implement Drupal's REST API. Here is a reference: https://www.drupal.org/docs/8/core/modules/rest/3-post-for-creating-content-entities

Summary

The Feeds solution is faster and easier to implement, so, to whatever degree that you have control, I recommend making the remote data available via URL (e.g. via RSS) and then consuming it with Feeds, which can be set to execute on a regular basis. There are also a number of handy companion modules for Feeds, such as Feeds Tamper and Feeds Extensible Parsers.

fi flag
Thank you! I am going with the REST API because the data needs to be POSTed from the remote server.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.