Skip to content
Advertisement

Salesforce to magento integration

    //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');

This is my code… I am just trying to create a lead in salesforce using this code. This is a sample php toolkit code for salesforce.

But when I am trying to run this code. It does not generate any lead in salesforce. My login credentials are correct and security token is also correct.

Where am I going wrong? I am using free developer account and following code for connection in 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>

Advertisement

Answer

i did print the value of result but it wasn’t working as well. As I was using partner wsdl i changed new SObject() to new stdClass() and it worked.. 🙂

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement