簡體   English   中英

在沒有Salesforce PHP工具包的情況下,如何使用PHP SoapClient對Salesforce進行Soap調用?

[英]How do I make Soap calls using PHP SoapClient to salesforce without the Salesforce PHP Toolkit?

$client = new SoapClient('enterprise.wsdl');
print_r($client->login(SFDC_LOGIN, SFDC_PASSWORD.SFDC_API_TOKEN));
$client->__setLocation(TOKEN_URL);

我收到一個錯誤:

致命錯誤:未捕獲的SoapFault異常:[UNKNOWN_EXCEPTION] UNKNOWN_EXCEPTION:未重置目標URL。 從登錄返回的URL必須在/Library/WebServer/Documents/custom/index.php:18中的SforceService中設置。

在這種情況下,它沒有提供太多有用的信息,但確實告訴我我是否需要設置目標URL或捕獲返回的URL? 任何幫助將非常感激。

注意:

我不想使用Salesforce PHP工具包,因為如果不需要的話,我不想向公司的Web服務器添加任何額外的東西。

好吧,所以在從aynber的想法中挖掘出來之后。 我想出了這個...

我從https://www.soapui.org為我的Mac下載了SoapUI-5.2.1。

從那里,我將該程序與Salesforce的Enterprise WSDL文件結合在一起。 使用該程序“預構建”肥皂呼叫我。 然后,我取出所需的碎片,並使用cURL提交肥皂信封。

這使我可以使用以前創建的帳戶ID /聯系人ID轉換銷售線索。 轉換潛在客戶后,我現在可以返回並修改機會ID,該ID也已創建潛在客戶轉換。

這是我想出的代碼...

$soapSubmission='<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:enterprise.soap.sforce.com"><soapenv:Header><urn:SessionHeader><urn:sessionId>'.$creds[0].'</urn:sessionId></urn:SessionHeader></soapenv:Header><soapenv:Body><urn:convertLead>';
        foreach($postInfo as $orderKey=>$values){
            $additionString='<urn:leadConverts>';
            if(isset($values['SFDC_IDs']['Account'])){
                $additionString.='<urn:accountId>'.$values['SFDC_IDs']['Account'].'</urn:accountId>';
            }
            if(isset($values['SFDC_IDs']['Contact'])){
                $additionString.='<urn:contactId>'.$values['SFDC_IDs']['Contact'].'</urn:contactId>';
            }
            $additionString.='<urn:convertedStatus>Converted</urn:convertedStatus>';
            $additionString.='<urn:doNotCreateOpportunity>true</urn:doNotCreateOpportunity>';
            $additionString.='<urn:leadId>'.$values['SFDC_IDs']['Lead'].'</urn:leadId>';
            $additionString.='<urn:overwriteLeadSource>false</urn:overwriteLeadSource>';
            $additionString.='<urn:ownerId>'.self::IT_SERVICE_ID.'</urn:ownerId>';
            $additionString.='<urn:sendNotificationEmail>false</urn:sendNotificationEmail>';
            $additionString.='</urn:leadConverts>';

            $soapSubmission.=$additionString;
        }
        $soapSubmission.='</urn:convertLead></soapenv:Body></soapenv:Envelope>';

        $ch=curl_init($creds[1]);
        curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
        curl_setopt($ch, CURLOPT_MAXREDIRS, 10);
        curl_setopt($ch,CURLOPT_TIMEOUT, 60);
        curl_setopt($ch,CURLOPT_POST,1);
        curl_setopt($ch,CURLOPT_POSTFIELDS,$soapSubmission);
          curl_setopt($ch, CURLOPT_HTTPHEADER, array(
            "cache-control: no-cache",
            "content-type: text/xml; charset=UTF-8",
            "SOAPAction: convertLead"
          ));
        $result=curl_exec ($ch);
        curl_close($ch);
        return $result;

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM