2013-01-07 94 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

我很高興你解決了它。只需指出,描述鉛和打印結果的區域並不是必需的,例如在那裏。