请帮我解决这个问题 我收到了这个错误。 [faultstring] => System.NullPointerException:尝试取消引用空对象 我正在为Sales force使用自定义对象集成。
require_once ('soapclient/SforcePartnerClient.php');
require_once ('soapclient/SforceHeaderOptions.php');
try {
$mySforceConnection = new SforcePartnerClient();
$mySforceConnection->createConnection("soapclient/partnerwsdl-sb.xml");
$mySforceConnection->login(USERNAME, PASSWORD.SECURITY_TOKEN);
// Define constants for the web service. We'll use these later
$parsedURL = parse_url($mySforceConnection->getLocation());
define ("_SFDC_SERVER_", substr($parsedURL['host'],0,strpos($parsedURL['host'], '.')));
define ("_WS_NAME_", 'WebToLeadServices');
define ("_WS_WSDL_", 'soapclient/WebToLeadServices-SB-V1.1.xml');
define ("_WS_ENDPOINT_", 'https://' . _SFDC_SERVER_ . '.salesforce.com/services/wsdl/class/' . _WS_NAME_);
define ("_WS_NAMESPACE_", 'http://soap.sforce.com/schemas/class/' . _WS_NAME_);
// SOAP Client for Web Service
$client = new SoapClient(_WS_WSDL_);
$sforce_header = new SoapHeader(_WS_NAMESPACE_, "SessionHeader", array("sessionId" => $mySforceConnection->getSessionId()));
$client->__setSoapHeaders(array($sforce_header));
$sObject = new stdclass();
$sObject->fullName = 'Sunil';
$sObject->country = 'India';
$sObject->budget = '1';
$sObject->type = 'Contact';
$sObject->dialingCode = '91';
$sObject->emailAddress = "XXXX";
$sObject->mobileNumber = "XXXXXXXX";
$sObject->source = "google";
$sObject->projectInterested = "Project";
$sObject->capturePoint = "XXXX.php";
$sObject->IPAddress = "XXXX";
$sObject->webbannerSource = "google";
$sObject->webbannerSize = "twitter";
$createResponse = $client->createLeadFromWeb(array($sObject));
} catch (Exception $e) {
echo '<pre>';
print_r($e);
echo '</pre>';
}
?>
</pre>
答案 0 :(得分:0)
我有解决方案 我们需要使用必填字段传递这样的变量 及其工作
$lead = new StdClass();
$lead->fullName = 'sunil';
$lead->mobileNumber = "1234567896";
$lead->emailAddress = "sunil@example.in";
$lead->source = "DIGITAL MARKETING";
$leadData = array('wl'=>$lead);
$response = $client->createLeadfromWeb($leadData);