Use curl to submit infusion legacy form

I have a php script that is using curl to submit a form to Infusion. I need to have a tag added to the record based on the submission of the form. I think that I can specify what form id I want submitted… but sheepishly I can’t for the life of me remember how to tell curl the form id. Please see the below function. I think I can just add a parameter to the $proper string, but I’m not sure. any help would be appreciated.

function send_to_infusion($count, $proper){

	$timeout = 30;
	$curl = curl_init();
	curl_setopt ($curl, CURLOPT_URL, "https://xxxx.infusionsoft.com/AddForms/processForm.jsp");
	curl_setopt ($curl, CURLOPT_TIMEOUT, $timeout);
	curl_setopt ($curl, CURLOPT_USERAGENT, sprintf("Mozilla/%d.0",rand(4,5)));
	## Below two option will enable the HTTPS option.
    curl_setopt ($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
    curl_setopt ($curl, CURLOPT_SSL_VERIFYHOST,  2);
	curl_setopt ($curl, CURLOPT_POST, $count);
	curl_setopt ($curl, CURLOPT_POSTFIELDS, $proper);   
	curl_setopt ($curl, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt ($curl, CURLOPT_FOLLOWLOCATION, 1);
    
	$code = curl_exec ($curl);
    curl_close ($curl);
	
	return $code;
	}

I believe you pass by POST params as in:

$fields = array(
‘inf_form_xid’ => urlencode( $inf_form_xid ),
‘inf_form_name’ => urlencode( $inf_form_name ),
‘infusionsoft_version’ => urlencode( $infusionsoft_version ),
‘inf_field_FirstName’ => urlencode( $inf_field_FirstName ),
‘inf_field_LastName’ => urlencode( $inf_field_LastName ),
‘inf_field_Email’ => urlencode( $inf_field_Email ),
‘inf_field_Phone1’ => urlencode( $inf_field_Phone1 ),
);

and then…

$ch=curl_init();
curl_setopt( $ch, CURLOPT_POST, count($fields) );
… //etc etc

the field to specify form Id can be passed as a parameter and it is labeled inf_form_xid

ok cool, that’s what I needed.

Thanks for answering this for me.

Just a word of caution - I mysteriously had an IP get blocked from hitting the Infusionsoft API. I honestly do not know what happened, but API support told me that …

… if the IP address wasn’t actually using the API and was submitting web forms through the url post action then the IP could have been blocked because these types of posts appear as a spambot submitting a web form, order form or landing page.

So that to me means that if you are using CURL and submitting webforms to Infusionsoft - this poses the potential of getting that IP blocked. Atleast that is my understanding.

Thanks,
Casey

1 Like

@Casey_Page
This is correct. Infusionsoft doesn’t suggest doing this as this type of action will look like a spambot filling out a webform. In the future additional security that is added to a web form, order form or landing page submission could stop these types of posts. If a post needs to be made from a server to Infusionsoft please utilize the API to accomplish this. The contact can be added through the API using this method:
https://developer.infusionsoft.com/docs/xml-rpc/#contact-create-a-contact-and-check-for-duplicates
The contact can then be added to a campaign using this method:
https://developer.infusionsoft.com/docs/xml-rpc/#funnel-achieve-a-goal

I would hate for you to build this out then have it stop working because security measures are added as this would stop contacts from being added to Infusionsoft.

I appreciate the word of caution. I actually scrapped the curl part from my script. the script was written several years ago and does still work, but when trying to adapt it for an existing form it would not work correctly. I think it is specifically because the form field names must match the form names.

What was working before (and does still work with the old curl script) was using the contact fields as the key values like Contact0FirstName etc. Once you change over to including Form specific Id, the contact fields as key values no longer works. so it was either re-do all the form logic that I had or re-write it using the api. I went the API route because it was going to be more robust.

1 Like

Those old legacy field names that start with Contact0 and the forms that go with them will submit and all data will be inserted into Infusionsoft even if you don’t have the fields in the web form in your Infusionsoft app (ie you add in GA fields to your form embed code on your site later on, but don’t update the web form in Infusionsoft to have those fields also). This is how it worked previously and those submit to a different URL than the new forms with the new field names that start with inf_field. For those, you MUST have every field match between the embed code and the form as it exists in Infusionsoft or the form fails. Perhaps that’s what you were running into. Still, totally best to use the API because of the possible spam identification as mentioned previously. :slight_smile:

1 Like