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
KroskKrosk 

Problem logging with PHP API

Hi everybody,

 

I have a problem while trying to login Salesforce, using the PHP API.

Here is the code i'm using :

 

 

define('SALESFORCE_USER', 'XXX');
define('SALESFORCE_PASS', 'XXX');
define('SALESFORCE_TOKEN', 'XXX');
define('SALESFORCE_WSDL', "XXX.wsdl");

require_once ('soapclient/SforceEnterpriseClient.php');
ini_set('soap.wsdl_cache_enabled', 0);
$crmHandle = new SforceEnterpriseClient();
try {
  $crmHandle->createConnection(SALESFORCE_WSDL);
} catch (Exception $e) {}

try {
  $crmHandle->login(SALESFORCE_USER, SALESFORCE_PASS . SALESFORCE_TOKEN);
} catch (Exception $e) {
  echo $e;
}

 

 

 

And i get the following error message :

 

SoapFault exception: [INVALID_LOGIN] INVALID_LOGIN: Invalid username, password, security token; or user locked out. in soapclient\SforceBaseClient.php:155 Stack trace: #0 [internal function]: SoapClient->__call('login', Array) #1 soapclient\SforceBaseClient.php(155): SoapClient->login(Array) #2 connect.php(33): SforceBaseClient->login('XXX', 'XXX') #3 {main}

 

Just one more information, i'm working on a sandbox,

maybe is it a reason to my problem ?

 

Any ideas about it ?

I'm a beginner with that and I need your help...

Thanks in advance

Best Answer chosen by Admin (Salesforce Developers) 
Park Walker (TAGL)Park Walker (TAGL)

As you suspected, the problem is that you are logging into a sandbox. Make sure that the sandbox suffix is appended to your user name (user@company.com.dev) and that you are using a token generated from the sandbox account. The other thing you need to do is to change the endpoint in the WSDL file from https://www.salesfoce.com to https://test.salesforce.com. with those three changes you should be able to log into your sandbox. You can either edit the WSDL file directory or update the endpoint in your code once you have created the connection, replacing 'www' with 'test'.

 

Park

All Answers

Park Walker (TAGL)Park Walker (TAGL)

As you suspected, the problem is that you are logging into a sandbox. Make sure that the sandbox suffix is appended to your user name (user@company.com.dev) and that you are using a token generated from the sandbox account. The other thing you need to do is to change the endpoint in the WSDL file from https://www.salesfoce.com to https://test.salesforce.com. with those three changes you should be able to log into your sandbox. You can either edit the WSDL file directory or update the endpoint in your code once you have created the connection, replacing 'www' with 'test'.

 

Park

This was selected as the best answer
KroskKrosk

Ok it works now, the problem was the endpoint in the WSDL.

Thanks for your help :)