Start New Discussion within our Web Development Community

Hi all. I've been trying to get this code to post to a https url for some time without any remedy. I'll give you all a basic rundown, I have a site that we're trying to generate leads off of, and we have a 3rd party crm system that we use to insert those leads to. This 3rd party CRM service gave me this document: to help me implement their API, but I've done everything and the leads still seem to not be dumping into the CRM.

The URL I'm supposed to post to is:

The test form I'm using is real simple:

<form action="scripts/curlPost.php" name="myform" id="myform" method="post">
<!-- Gender --><input type="text" id="insured_1_gender" name="insured_1_gender" value="F" />
<!-- DOB --><input type="text" id="DOB" name="DOB" value="08/30/1988" />
<!-- Tobacco --><input type="text" id="insured_1_tobacco" name="insured_1_tobacco" value="none" />
<!-- First Name --><input type="text" id="first_name" name="first_name" value="test" />
<!-- Last Name --><input type="text" id="last_name" name="last_name" value="lead" />
<!-- City --><input type="text" id="address_1_city" name="address_1_city" value="austin" />
<!-- State --><input type="text" id="address_1_state" name="address_1_state" value="TX" />
<!-- Address --><input type="text" id="Address1" name="Address1" value="1234 front streeto" />
<!-- Address 2 --><input type="text" id="Address2" name="Address2" value="apt726" />
<!-- Zip Code --><input type="text" id="address_1_zip" name="address_1_zip" value="78728" />
<!-- Home Phone --><input type="text" id="phone_1" name="phone_1" value="8062313333" />
<!-- Work Phone --><input type="text" id="WorkPhone" name="WorkPhone" value="8062313333" />
<!-- Cell Phone --><input type="text" id="CellPhone" name="CellPhone" value="8062313333" />
<!-- Income --><input type="text" id="Income" name="Income" value="100000" />
<!-- Email --><input type="text" id="email" name="email" value="" />
<!-- IP Address --><input type="text" id="IPAddress" name="IPAddress" value="" />
<!-- Term Length --><input type="text" id="typeofinsurance" name="typeofinsurance" value="20" />
<!-- Coverage Amount --><input type="text" id="coverageamount" name="coverageamount" value="50000" />
<!-- Insurance Reason --><input type="text" id="InsuranceReason" name="InsuranceReason" value="Family Protection" />
<!-- Height --><input type="text" id="insured_1_height" name="insured_1_height" value="72" />
<!-- Weight --><input type="text" id="insured_1_weight" name="insured_1_weight" value="200" />
<!-- User Name --><input type="text" id="UserName" name="UserName" value="luisestrada" />
<!-- AuthorizationCode --><input type="text" id="AuthorizationCode" name="AuthorizationCode" value="TheLif100819091951" /><br />
<input type="submit" name="submit">

And my php code using cURL is:


header("Content-Type: text/html");

//create variables
$alissusername = "luisestrada";
$authorizationcode = "TheLif100819091951";
$DOB = $_POST['DOB'];
$gender = $_POST['insured_1_gender'];
$tobacco = $_POST['insured_1_tobacco'];
$firstname = $_POST['first_name'];
$lastname = $_POST['last_name'];

$heightfeet = $_POST['insured_1_feet'];
$heightinches = $_POST['insured_1_inches'];
//$heightconverted = $heightfeet * 12 + $heightinches;
$heightconverted = $_POST['insured_1_height'];

$weight = $_POST['insured_1_weight'];
$termlength = $_POST['typeofinsurance'];
$coverageamount = $_POST['coverageamount'];
$premiummode = $_POST['paymentfrequency'];
$city = $_POST['address_1_city'];
$state = $_POST['address_1_state'];
$zip = $_POST['address_1_zip'];
$county = $_POST['address_1_county'];
$phone = $_POST['phone_1'];
$email = $_POST['email'];
$keyword = $_POST['keyword'];
$blank = "";

//set POST variables
$url = '';
$fields = array(

//url-ify the data for the POST
$counter = 0;
foreach($fields as $key=>$value) { 
	if ($counter > 0) {
		$fields_string .= '&';
	$fields_string .= $key.'='.$value; 

//open connection
$ch = curl_init($url);

//set the url, number of POST vars, POST data
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POST,1);
curl_setopt($ch, CURLOPT_POSTFIELDS,$fields_string);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION  ,1);
curl_setopt($ch, CURLOPT_HEADER      ,0);  // DO NOT RETURN HTTP HEADERS

//execute post
$result = curl_exec($ch);

if(curl_exec($ch) === false) {
    echo 'Curl error: ' . curl_error($ch);
} else {
    echo 'Operation completed without any errors';

//close connection

//echo($result . "<br>");
echo($fields_string . "<br>");

Do you all see anything that I'm doing wrong? When I try to submit this in a regular form post with the url, it works fine and takes me to a page in xml that says <string>Added</string> and the lead gets added into the crm system.

Any help would be greatly appreciated, and I can donate to the person that helps me solve this.

Could you detail how you resolved this please as i am having the exact same issue

It had something to do with server configuration, I moved the script to another server and it worked perfectly fine. Not sure what the EXACT problem was, but it was something server side that wasn't allowing me to use cURL. You might want to check your php settings to make sure cURL is enabled.

This question has already been answered. Start a new discussion instead.