首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >salesforce Web2Lead上的Web2Lead验证

salesforce Web2Lead上的Web2Lead验证
EN

Stack Overflow用户
提问于 2014-02-17 21:21:36
回答 1查看 974关注 0票数 0

我正试图在php包装器中实现一个验证过程,以便新的web要领导表单(salesforce)。

引导会自动提交,并且完全忽略验证过程。

代码语言:javascript
复制
if (empty($_POST["first_name"]))
  {$firstNameErr = "Name is required";}
else
  {$first_name = test_input($_POST["first_name"]);}

 if (empty($_POST["last_name"]))
   {$lastNameErr = "Email is required";}
 else
   {$last_name = test_input($_POST["last_name"]);}

 if (empty($_POST["phone"]))
   {$phoneErr = "";}
 else
{$phone = test_input($_POST["phone"]);}

 if (empty($_POST["email"]))
   {$emailErr = "";}
 else
   {$email = test_input($_POST["email"]);}

 if (empty($_POST["company"]))
    {$companyNameErr = "Gender is required";}
 else
    {$company = test_input($_POST["company"]);}

以下是完整的php代码:

代码语言:javascript
复制
<?php

//Initialize the $query_string variable for later use
$query_string = "";
$firstNameErr = $lastNameErr = $phoneErr = $emailErr = $companyNameErr = "";
$first_name = $last_name = $phone = $email = $company = "";


//If there are POST variables
if ($_POST) {

//Initialize the $kv array for later use
$kv = array();

//For each POST variable as $name_of_input_field => $value_of_input_field
foreach ($_POST as $key => $value) {

//Set array element for each POST variable (ie. first_name=Arsham)
$kv[] = stripslashes($key)."=".stripslashes($value);

  if (empty($_POST["first_name"]))
    {$firstNameErr = "Name is required";}
  else
    {$first_name = test_input($_POST["first_name"]);}

  if (empty($_POST["last_name"]))
    {$lastNameErr = "Email is required";}
  else
    {$last_name = test_input($_POST["last_name"]);}

  if (empty($_POST["phone"]))
    {$phoneErr = "";}
  else
    {$phone = test_input($_POST["phone"]);}

  if (empty($_POST["email"]))
    {$emailErr = "";}
  else
    {$email = test_input($_POST["email"]);}

  if (empty($_POST["company"]))
    {$companyNameErr = "Gender is required";}
  else
    {$company = test_input($_POST["company"]);}

}


//Create a query string with join function separted by &
$query_string = join("&", $kv);
}
//Check to see if cURL is installed ...
if (!function_exists('curl_init')){
die('Sorry cURL is not installed!');
}

//The original form action URL from Step 2 :)
$url = 'https://www.salesforce.com/servlet/servlet.WebToLead?encoding=UTF-8';

//Open cURL connection
$ch = curl_init();

//Set the url, number of POST vars, POST data
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, count($kv));
curl_setopt($ch, CURLOPT_POSTFIELDS, $query_string);

//Set some settings that make it all work :)
curl_setopt($ch, CURLOPT_HEADER, FALSE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, FALSE);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);

//Execute SalesForce web to lead PHP cURL
$result = curl_exec($ch);

//close cURL connection
curl_close($ch);

?>
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-08-30 20:51:11

嗯,完全重新开发了一个框架,允许我做这样的事情。

如果有人想要一个salesforce web2lead,它可以很容易地连接到任何类型的表单:

https://github.com/jagmitg/Salesforce-Web2lead

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/21839498

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档