salesforce api从表单中添加潜在客户

时间:2016-02-17 01:01:32

标签: php salesforce

我正在尝试将联系表单中的潜在客户添加到salesforce。目前我正在使用这个解决方案,通过我们假设的Web-to-Lead解决方案:

if (isset($_POST['submit'])) {

        $ch_register_first_name = $_POST['ch_register_first_name'];
        $ch_register_last_name = $_POST['ch_register_last_name'];
        $ch_register_dob = $_POST['ch_register_dob'];
        $ch_register_phone = $_POST['ch_register_phone'];
        $ch_register_email = $_POST['ch_register_email'];
        $ch_register_street = $_POST['ch_register_street'];
        $ch_register_street2 = $_POST['ch_register_street2'];
        $ch_register_city = $_POST['ch_register_city'];
        $ch_register_state = $_POST['ch_register_state'];
        $ch_register_zip = $_POST['ch_register_zip'];

       //set POST variables
        $url = 'https://test.salesforce.com/servlet/servlet.WebToLead?encoding=UTF-8';
        $fields = array(
                'last_name'=>urlencode($ch_register_first_name),
                'first_name'=>urlencode($ch_register_last_name),
                'street'=>urlencode($ch_register_street),
                'city'=>urlencode($ch_register_city),
                'state'=>urlencode($ch_register_state),
                'zip'=>urlencode($ch_register_zip),
                'company'=>urlencode($company),
                'description'=>urlencode($ch_register_dob),
                'email'=>urlencode($ch_register_phone),
                'phone'=>urlencode($ch_register_email),
                'mycustomefieldid' => urlencode($ch_register_dob), // custom field
                'oid' => $ch_register_salesforce_id, // insert with your id
                'retURL' => urlencode('http://thank-you/'), // sending this just in case
                'debug' => '1',
                'debugEmail' => urlencode("email@email.com"), // your debugging email
        );

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

        //open 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($fields));
        curl_setopt($ch,CURLOPT_POSTFIELDS,$fields_string);

        curl_setopt($ch,CURLOPT_SSL_VERIFYPEER, FALSE);
        curl_setopt($ch,CURLOPT_RETURNTRANSFER, TRUE);
        curl_setopt($ch,CURLOPT_FOLLOWLOCATION, TRUE);

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

        //close connection
        curl_close($ch);
    }

这样做的问题(如果我使用Web-to-Lead解决方案是正确的)最大限制是24小时内500。这个表格的某些事件将在当天使用,肯定会超过500。我怎样才能使用我读过的API?或者我应该将本地保存到数据库,然后使用Force api?

运行批处理

0 个答案:

没有答案