2013-01-07 68 views
2
//Create a new partner object 
    $connection = new SforcePartnerClient(); 

    //Create the SOAP connection 
    try { 
      $connection->createConnection(salesforce_wsdl); 
    } catch (Exception $e) { 
      //Salesforce could be down, or you have an error in configuration 
      //Check your WSDL path 
      echo "Salesforce could be down"; 
    } 

    //Pass login details to Salesforce 
    try { 
      $connection->login(salesforce_username, salesforce_password . salesforce_token); 
    } catch (Exception $e) { 
      //Make sure your username and password is correct 
      echo "usename/password incorrect"; 
    } 

    //Describing the Leads object and printing the array 
    $describe = $connection->describeSObjects(array('Lead')); 
    print_r($describe); 

    //Create New Lead 
    $leadFirstName = "John"; 
    $leadLastName = "Doe"; 
    $leadCompany = "abc"; 
    $leadEmail = "[email protected]"; 

    //Creating the Lead Object 
    $lead = new sObject(); 
    $lead->type = 'Lead'; 
    $lead->fields = array(
      'FirstName' => $leadFirstName, 
      'LastName' => $leadLastName, 
      'Company' => $leadCompany, 
      'Email' => $leadEmail 
    ); 

    //Submitting the Lead to Salesforce 
    $result = $connection->create(array($lead), 'Lead'); 

这是我的代码...我只是试图在使用此代码的salesforce中创建销售线索。这是salesforce的一个php工具包示例代码。Salesforce与magento的集成

但是当我试图运行此代码。它在salesforce中没有产生任何领先优势。 我的登录凭证是正确的,安全令牌也是正确的。

我哪里错了?我正在使用免费开发者帐户和以下代码在partner.wsdl.xml中进行连接:

<!-- Soap Service Endpoint --> 
    <service name="SforceService"> 
     <documentation>Sforce SOAP API</documentation> 
     <port binding="tns:SoapBinding" name="Soap"> 
      <soap:address location="https://login.salesforce.com/services/Soap/c/26.0"/> 
     </port> 
    </service> 
+0

$结果会告诉你为什么它没有被创建。 – superfell

回答

0

我确实打印了结果的值,但它不起作用。当我使用合作伙伴WSDL,我改变新的sObject()到新stdClass的()和它的工作.. :)

0

我很高兴你解决了它。只需指出,描述铅和打印结果的区域并不是必需的,例如在那里。