2013-11-25 26 views
0

我有這個自定義web2lead表單,但它沒有向salesforce發送任何數據。這是幾個月前創建的,我無法弄清楚什麼是錯的。Salesforce web2lead表單不發送數據給salesforce

這是形式處理腳本,它inlcudes的sleaforce代碼:

<?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  = "[email protected]"; 
    $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("[email protected]", "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="[email protected]"; 

    //$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("[email protected]", $emailSubject, $emailBody, $emailHeader); 
    //echo "mail: $emailBody <br> $emailTo"; 

    # Redirect user to success page 

    header("Location: http://www.mysite.net/sent.html"); 
} 
} 
?> 
+0

這是很多代碼,並且對錯誤的描述非常模糊。你有沒有做過任何調試?你知道錯誤發生在哪裏嗎?在驗證中?在捲曲代碼?當它試圖發送電子郵件?你可以嘗試爲我們縮小範圍嗎? – andrewsi

+0

我不確定從哪裏開始。我所知道的是它正在發送數據,現在不是。 –

+0

發送數據是什麼意思?它是否通過CURL調用添加到Salesforce?你還收到電子郵件嗎?你是否檢查過服務器上的錯誤日誌,看看裏面有沒有什麼東西?最近有沒有在服務器上升級? – andrewsi

回答

0

一種可能性是,ORGID得到了演示或測試組織代替,或者某些領域已經改變了您綁定到從表格。