将$ _POST数据存储到本地数据库,然后通过Web将其发送到Salesforce以获取表单

时间:2012-03-13 17:27:56

标签: php salesforce

我正在为我的网站创建一个潜在客户表单。我想在本地和Salesforce中存储数据。

这是我到目前为止所做的:

if('POST' == $_SERVER['REQUEST_METHOD']) {
    $leads = array($_POST["myValue1"], $_POST["myValue2"], $_POST["myValue3"],
     $_POST["myValue4"], $_POST["myValue5"], $_POST["myValue6"], 
     $_POST["myValue7"], $_POST["myValue8"], $_POST["myValue9"], 
     $_POST["myValue10"] );

$qry = $dbh->prepare(
    'INSERT INTO leads (myValue1, myValue2, myValue3, myValue4, myValue5, 
     myValue6, myValue7, myValue8, myValue9, myValue10) 
     VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)');
$qry->execute($leads);

//I want to send the array $leads to Salesforce at this point

目前,我正在使用以下内容通过网络将数据发送到Salesforce

<form name="MyForm" id="MyForm" method="post" action="https://www.salesforce.com/servlet/servlet.WebToLead?encoding=UTF-8" >        
<input type=hidden name="oid" value="SALESFORCE VALUE GOES HERE">
<input type=hidden name="retURL" value="http://www.mysite.com/thank-you">
<input type=hidden name="lead_source" value="web">
<input type=hidden name="Campaign_ID" value="SALESFORCE VALUE GOES HERE">
<input type=hidden name="recordType" value="SALESFORCE VALUE GOES HERE">
}

基本上,在本地存储数据后如何启动$_POST?谢谢!

1 个答案:

答案 0 :(得分:3)

$ch = curl_init( $url );
curl_setopt($ch, CURLOPT_POSTFIELDS, $_POST);
$responce = curl_exec( $ch );
//debug
$err      = curl_errno( $ch );
$errmsg   = curl_error( $ch );
$header   = curl_getinfo( $ch );
curl_close( $ch );