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
snappersnapper 

Trouble logging in with PHP API

Hi all,

 

I am having issues while trying to login via the Salesforce API, I keep getting the error:

INVALID_LOGIN: Invalid username, password, security token; or user locked out.

 

I know that the username and password are correct, i have just reset my security token and appending that to the end of my password also didnt work.

 

Below is a copy of the code that I'm using:

 

ni_set("soap.wsdl_cache_enabled", "0" ) ;
require_once (SOAP_CLIENT_BASEDIR.'soapclient/SforcePartnerClient.php');
require_once (SOAP_CLIENT_BASEDIR.'userAuth.php');
try {
   $mySforceConnection = new SforcePartnerClient();
   $mySoapClient = $mySforceConnection->createConnection(SOAP_CLIENT_BASEDIR. "soapclient/partner.wsdl.xml");
   $mylogin = $mySforceConnection->login($USERNAME, $PASSWORD);

   echo "***** Login Info*****<br />";
   echo $mySforceConnection->getSessionId();
   print_r($mylogin);
} catch (Exception $e) {
   echo $mySforceConnection->getLastRequest();
   echo $e->faultstring;
}

 

Any one got any ideas on how I can fix this? Or why this could be happening?

 

All and any help is very appreciated, thanks in advance.

ptepperptepper

Have you checked your user settings to see if you got locked out? If you used the wrong password 3 times, than you would be and you need to reset it. This would of course also prevent you from logging into salesforce.

snappersnapper

Thank you for your reply, but i can still log into the Salesforce site.

SuperfellSuperfell

Make sure the credentials you're using are for the WSDL you're using (e.g. you're not using a production WSDL, and sandbox credentials). Also you can login to the web app and see what's reported in login history.

snappersnapper

Thanks very much for your help, managed to fix the problem, I dont think SOAP was working correctly on the server, I think it was the reinstallation of SOAP that fixed the issue.