Salesforce到Magento的集成

wkyowqbh  于 2022-11-12  发布在  其他
关注(0)|答案(2)|浏览(127)
//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 = "chetan@abc.com";

     //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中生成任何线索。我的登录凭据是正确的,安全令牌也是正确的。
我哪里出错了?我正在使用免费的开发者帐户和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>
monwx1rj

monwx1rj1#

我很高兴你解决了这个问题。只是要指出的是,描述销售线索和打印结果的区域不是必需的,例如就在那里。

evrscar2

evrscar22#

我确实打印了result的值,但效果不太好。当我使用合作伙伴wsdl时,我将new SObject()更改为new stdClass(),它工作了..:)

相关问题