$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必须在/Library/WebServer/Documents/custom/index.php:18中的SforceService中设置
在这种情况下,这并没有提供很多有用的信息,它确实告诉我,我需要设置目标URL或捕获返回的URL?任何帮助将不胜感激。
注意:
我不想使用Salesforce PHP工具包,因为我不想在我的公司网络服务器上添加额外的东西,如果我不需要的话。
答案 0 :(得分:0)
好的,所以经过一些挖掘aynber的想法。我想出了这个......
我从https://www.soapui.org为我的mac下载了SoapUI-5.2.1。
从那里我将该程序与salesforce的Enterprise WSDL文件结合起来。使用该程序来预先构建"肥皂叫我。然后我拿出我需要的碎片并用cURL提交肥皂信封。
这允许我使用以前创建的帐户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;