function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

How to get a connection to the salesforce?

Hi, I am trying to push some data to the salesforce from my web site. Here is the testing code. However, when it runs, there is an error occured with the LOGIN line: "INVALID_LOGIN: Invalid username or password or locked out."





    $USERNAME = "";
    $PASSWORD = "password";

    define("SOAP_CLIENT_BASEDIR", "register-plus/salesforce_php");

    require_once (SOAP_CLIENT_BASEDIR.'/SforceEnterpriseClient.php');
    require_once (SOAP_CLIENT_BASEDIR.'/SforceHeaderOptions.php');
    require_once (SOAP_CLIENT_BASEDIR.'/userAuth.php');

    try {
        $mySforceConnection = new SforceEnterpriseClient();
        $mySoapClient =      $mySforceConnection->createConnection(SOAP_CLIENT_BASEDIR.'/enterprise.wsdl.xml');
        $mylogin = $mySforceConnection->login($USERNAME, $PASSWORD);
        $sObject = new stdclass();
        $sObject->FirstName = 'Smith';
        $sObject->LastName = 'John';
        $sObject->Phone = '510-555-5555';

        $createResponse = $mySforceConnection->create(array($sObject), 'Leads');

        $ids = array();
        foreach ($createResponse as $createResult) {
            array_push($ids, $createResult->id);

        } catch (Exception $e) {
            echo $mySforceConnection->getLastRequest();
            echo $e->faultstring;


Can you login by using this user id and pwd in SFDC?



  $PASSWORD = "password";

Sorry,  i do not understand. It does not work if we: $USERNAME =;  it should be a string type...