Good afternoon everyone,
I’m having the following problem:
I have a web form to capture leads.
Suite crm gives me the option to send those leads to the module through the web to module form but that form only accepts an action attribute.
My form on the landing page uses a php script to:
1 save the data to a db,
2 send an email with the data
3 perform the marketing campaign conversion
I have tried to send the data to the entry point of the leads module by post request but it gives me a CORS error, so I decided to make a PHP script to send the form data using cURL. the script is as follows:
$ URL = “the url of the module entry point”;
$ USER = “Mozilla / 5.0 (Macintosh; Intel Mac OS X 10.9; rv: 50.0) Gecko / 20100101 Firefox / 50.0”;
$ ENC = “Content-type: multipart / form-data”;
$ handler = curl_init ($ URL);
$ formdata = file_get_contents (“php: // input”);
$ data = json_decode ($ formdata);
$ lead is an array with the fields in format: ‘field’ => value, where value is: $ value = $ data-> field
curl_setopt ($ handler, CURLOPT_USERAGENT, $ USER);
curl_setopt ($ handler, CURLOPT_HTTPHEADER, [$ ENC]);
curl_setopt ($ handler, CURLOPT_CONNECTTIMEOUT, 100);
curl_setopt ($ handler, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt ($ handler, CURLOPT_RETURNTRANSFER, true);
curl_setopt ($ handler, CURLOPT_HEADER, true);
curl_setopt ($ handler, CURLOPT_POST, true);
curl_setopt ($ handler, CURLOPT_POSTFIELDS, $ lead);
$ post_data = curl_exec ($ handler);
curl_close ($ handler);
the problem is that the leads are not loaded. for some reason the crm is not understanding the data correctly
I think this is a very common problem and that many users have, however there is no information about it.
Thank you
Best regards
Pablo Pimas