通过对等方重置TCP连接 - Salesforce - PHP

时间:2018-05-16 09:27:08

标签: php apache web-services curl salesforce

在使用网络服务发送潜在客户信息后,我们突然开始从“Salesforce”获得“通过对等方重置TCP连接”响应。

我们使用的技术堆栈: 操作系统:Redhat Linux(RHEL) Web服务器:APACHE Web脚本语言:PHP 使用CURL发送详细信息。

向Salesforce发送请求发送潜在客户的代码段是......

/*****************************************************************************************************/
     /* Purpose           : Sending request to sales-force for lead generation
     /* Inputs       : $pStrPostArr :: Post data array.
     /* Returns      : None.
     /* Created By   : Jaiswar Vipin Kumar R.
     /*****************************************************************************************************/
     function send($pStrPostArr = array()){
           /* if post data is empty then do needful */
           if (empty($pStrPostArr)){
                /* return status */
                return false;
           }

           /* set POST variables */
        $strDestiantionURL = 'https://www.salesforce.com/servlet/servlet.WebToLead?encoding=UTF-8';
           /* removed used index */
           unset($pStrPostArr['desitnationURL']);

           /* if destination URL is not set then do needful */
           if (empty($strDestiantionURL)){
                /* return status */
                return false;
           }

           /* variable initialization */
           $strFields = '';


        /* url-ify the data for the POST */
        foreach($pStrPostArr as $strKey=>$strValue) { 
                if($strFields == ''){
                     $strFields .= $strKey.'='.$strValue;
                }else{
                     $strFields .= '&'.$strKey.'='.$strValue; 
                }
           }
       // rtrim($strFields,'&');
        if(isset($_COOKIE['debug'])){
                //print_r($pStrPostArr);
                echo $strFields;exit;
           }
        /* open connection */
        $ch = curl_init($strDestiantionURL);

        /* set the url, number of POST vars, POST data */
        curl_setopt($ch,CURLOPT_URL,$strDestiantionURL);
        curl_setopt($ch,CURLOPT_POST,count($pStrPostArr));
       curl_setopt($ch,CURLOPT_POSTFIELDS,$strFields);

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


        /* execute post */
        $this->_strReponse           = curl_exec($ch);
           /* Request Body */
           $this->_strRequestBody     = curl_getinfo($ch);

           if($this->_strReponse === FALSE){
                $this->_strError     = curl_error($ch);
           }

        /* close connection */
        curl_close($ch);
    }

发送潜在客户信息数据集是:

Array
(
    [desitnationURL] => https://www.salesforce.com/servlet/servlet.WebToLead?encoding=UTF-8
    [first_name] => Jaiswar
    [last_name] => Vipin+Kumar+R
    [company] => PocketApp
    [job_title__c] => 
    [country_c__c] => 
    [appdetail] => app development & designing
    [email] => vipin.jaiswar%40pocketapp.co.uk
    [phone] => %2B919773596947
    [Lead_Budget__c] => Undisclosed
    [description] => Fill+out+the+form+below+with+your+requirments+and+we+will+get+back+to+you+as+soon+as+possible.+Alternatively%2C+send+an+email+to+sales%40pocketapp.co.uk+or+give+us+a+call+on+%2B44+20+7183+4388
    [oid] => XXXXXXXXXXXXXXX
    [sfga] => XXXXXXXXXXXXXXX
    [retURL] => https://www.pocketapp.co.uk/thank-you/
    [lead_source] => Web
    [source__c] => https://www.semrush.com/siteaudit/campaign/472189/review/
    [medium__c] => -
    [campaign__c] => -
    [term__c] => -
    [content__c] => 
    [Visitor_ID__c] => -
    [gclid__c] => -
    [Count_of_Sessions__c] => 1
    [Count_of_Pageviews__c] => 1
    [00ND0000006RIpG] => 
    [00ND0000006RHJY] => 
    [00ND0000006RHJd] => 
    [00ND0000006RHJi] => 
    [00ND0000006RHJs] => 
    [00ND0000006RHJn] => 
    [00ND00000064Guy] => 
    [00ND00000064Gv3] => 
)

请你帮助我们,我们需要做些什么改变才能让这个开始工作?

1 个答案:

答案 0 :(得分:1)

Salesforce移动了web2lead端点,您需要更改目标网址以使用webto.salesforce.com而不是www.salesforce.com 见KB article