我有这个自定义web2lead表单,但它没有向salesforce发送任何数据。这是几个月前由某人创造的,我无法弄清楚出了什么问题。
这是表单处理脚本,它包含了一些简单的代码:
<?php
/*error_reporting(E_ALL & ~E_NOTICE);
date_default_timezone_set("America/New_York");
ini_set('display_errors', 0);
ini_set('display_startup_errors', 0);*/
session_start();
//print_r($_POST);
//die;
function DoStripSlashes($fieldValue) {
if ( get_magic_quotes_gpc() ) {
if (is_array($fieldValue) ) {
return array_map('DoStripSlashes', $fieldValue);
} else {
return stripslashes($fieldValue);
}
} else {
return $fieldValue;
}
}
function FilterCChars($theString) {
return preg_replace('/[\x00-\x1F]/', '', $theString);
}
function CheckEmail($email, $optional) {
if ( (strlen($email) == 0) && ($optional === kOptional) ) {
return true;
} elseif ( eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$", $email) ) {
return true;
} else {
return false;
}
}
//$ini_array = parse_ini_file("form_values.ini");
//print_r($ini_array);
////////////////////////honeypot check////////////////////////////////////////
if(isset($_POST['userComment']) == true && $_POST['userComment'] != ""){
$_SESSION['prev_value']=$_POST;
header("Location: free-quick-quote-sftest.php?honey=1");
exit();
}
////////////////////////////////////////////////////////////////////////////////////////
////////////////////////Arithmatic check////////////////////////////////////////
if(isset($_SESSION['arrval']) && isset($_POST['arrval']) && $_SESSION['arrval'] != $_POST['arrval']){
$_SESSION['prev_value']=$_POST;
header("Location: free-quick-quote-sftest.php?arrval=1");
exit();
}
////////////////////////////////////////////////////////////////////////////////////////
////////////////////////html check////////////////////////////////////////
if(isset($_POST['comments'])) {
$fbk=$_POST['comments'];
$fbk2=strip_tags($fbk);
}
if(isset($_POST['comments']) && $_POST['comments']!=$fbk2){
$_SESSION['prev_value']=$_POST;
header("Location: free-quick-quote-sftest.php?insertion=1");
exit();
}
////////////////////////////////////////////////////////////////////////////////////////
if(isset($_POST['fullname'])) {
$name = DoStripSlashes( $_POST['fullname'] );
$email = DoStripSlashes( $_POST['email'] );
$phone =DoStripSlashes( $_POST['phone'] );
$traveltype = DoStripSlashes($_POST['traveltype']);
$triptype = "";
if(isset($_POST['triptype']) == true) {
$triptype = DoStripSlashes($_POST['triptype']);
}
$departure_date = DoStripSlashes( $_POST['departure_date'] );
$departure_time = DoStripSlashes( $_POST['departure_time'] );
$departure_city_state = DoStripSlashes( $_POST['departure_city_state'] );
$destination_info = DoStripSlashes( $_POST['destination_info'] );
$hours = DoStripSlashes( $_POST['hours'] );
$service_type = DoStripSlashes( $_POST['service_type'] );
$vehicle_type = DoStripSlashes( $_POST['vehicle_type'] );
$heard = DoStripSlashes( $_POST['heard'] );
if(isset($_POST['other_comments']))
$heard_comments = DoStripSlashes( $_POST['other_comments'] );
$comments = DoStripSlashes( $_POST['comments'] );
if($heard=="Other"){
$heard=$heard_comments;
}
}
//print_r($_POST);
$validationFailed = false;
if ( $validationFailed === false ) {
$field_name = array();
$debug = 1;
$debugEmail = "myemail@gmail.com";
$oid = "myoid";
$prefix = "00N30000006m";
if(isset($name))
$newname = explode(" ", $name);
$first_name =(!empty($newname[0])) ? $newname[0] : "unspecified";
$last_name = (!empty($newname[1])) ? $newname[1] : "unspecified";
if(isset($departure_city_state))
$departure = explode(",", $departure_city_state);
if(!isset($departure[0]))
$departure[0] = "";
if(!isset($departure[1]))
$departure[1] = "";
if(!isset($departure[2]))
$departure[2] = "";
if(isset($destination_info))
$destination = explode(",", $destination_info);
if(!isset($destination[0]))
$destination[0] = "";
if(!isset($destination[1]))
$destination[1] = "";
if(!isset($destination[2]))
$destination[2] = "";
if(isset( $field_name['debug'])) {
// Identify the name="field_name as key="value"
$field_name['debug'] = "1";
$field_name['oid'] = $oid;
$field_name['retURL'] = "http://www.mysite.net";
//departure city
$field_name['00N30000006mRon'] = trim($departure[0]);
//departure state
$field_name['00N30000006mRpk'] = trim($departure[1]);
//departure date/time
$field_name['00N30000006mRpf'] = $departure_date . " " . $departure_time;
//destination city
$field_name['00N30000006mRpp'] = trim($destination[0]);
//destination state
$field_name['00N30000006mRpu'] = trim($destination[1]);
//hours
$field_name['00N30000006mRpz'] = $hours;
//special requests
$field_name['00N30000006mRqE'] = $comments;
//passengers
$field_name['00N30000006mRde'] = "1";
//vehicle
$field_name['00N30000006mRqO'] = $vehicle_type;
//referral source
$field_name['00N30000006oJV0'] = $heard;
//occasion
$field_name['00N30000006mRq4'] = $service_type;
$field_name['first_name'] = $first_name;
$field_name['last_name'] = $last_name;
$field_name['phone'] = $phone;
$field_name['email'] = $email;
$field_name['lead_source'] = "Web";
}
$post_items = array();
foreach($field_name as $key=>$value){
$post_items[] = $value."=".$key;
}
// $post_string = implode("&",$post_items);
// $post_string = urlencode($post_string);
$curl_connection = curl_init("https://www.salesforce.com/servlet/servlet.WebToLead?encoding=UTF-8");
curl_setopt($curl_connection, CURLOPT_CONNECTTIMEOUT, 30);
//curl_setopt($curl_connection, CURLOPT_USERAGENT,"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)");
curl_setopt($curl_connection, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.1.4322)');
curl_setopt($curl_connection, CURLOPT_HEADER, 1);
curl_setopt($curl_connection, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl_connection, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($curl_connection, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($curl_connection, CURLOPT_POST, 1);
//$headers = array();
//$headers['Content-Type'] = 'application/x-www-form-urlencoded';
//$headers['Content-Length'] = strlen($post_string);
//curl_setopt($curl_connection, CURLOPT_HTTPHEADER, $headers);
curl_setopt($curl_connection, CURLOPT_POSTFIELDS, http_build_query($field_name));
//curl_setopt($curl_connection, CURLOPT_VERBOSE, 1);
$result = curl_exec($curl_connection);
curl_close($curl_connection);
//mail("developncode@gmail.com", "Salesforce", $result);
# Email to Form Owner
$emailSubject = FilterCChars("Transportation Quote Request");
if(isset($name)) {
$emailBody =
"<h1>Transportation Quote Request</h1><br/>"
. "<strong>Name:</strong> $name<br/>"
. "<strong>Email:</strong> $email<br/>"
. "<strong>Phone:</strong> $phone<br/>"
. "<strong>Travel Type:</strong> $traveltype<br/>"
. "<strong>Trip Type:</strong> $triptype<br/>"
. "<strong>Pickup date:</strong> $departure_date<br/>"
. "<strong>Pickup time:</strong> $departure_time<br/>"
. "<strong>Pickup city, state, zip:</strong> $departure_city_state<br/>"
. "<strong>Dropoff city, state, zip:</strong> $destination_info<br/>"
. "<strong>Requested hours:</strong> $hours<br/>"
. "<strong>Service type:</strong> $service_type<br/>"
. "<strong>Vehicle type:</strong> $vehicle_type<br/>"
. "<strong>How did you hear about us:</strong> $heard<br/>"
. "<strong>Comments:</strong> $comments<br/>"
. "<br/><br/>"
. "www.mysite.com<br/>"
. "";
}
$emailTo="myemail@gmail.com";
//$emailTo=$ini_array[$service_type];
if(isset($email)) {
$emailFrom = FilterCChars("$email");
$emailHeader = "From: $emailFrom\n"
. "MIME-Version: 1.0\n"
. "Content-type: text/html\n"
. "Content-transfer-encoding: 7bit\n";
mail($emailTo, $emailSubject, $emailBody, $emailHeader);
//mail("developncode@gmail.com", $emailSubject, $emailBody, $emailHeader);
//echo "mail: $emailBody <br> $emailTo";
# Redirect user to success page
header("Location: http://www.mysite.net/sent.html");
}
}
?>
答案 0 :(得分:0)
一种可能性是OrgID被演示或测试组织取代,或者某些字段已经从表单中更改了。
答案 1 :(得分:0)
$oid = "SPECIFY_YOUR_SALESFORCE_INSTANCE_ID";
$prefix = "00N30000006m";
并非必需
对于沙盒:
$curl_connection = curl_init("https://www.test.salesforce.com/servlet/servlet.WebToLead?encoding=UTF-8");
用于生产
$curl_connection = curl_init("https://www.login.salesforce.com/servlet/servlet.WebToLead?encoding=UTF-8");