Contents

Login

Sample Login Call

<?php
// SOAP_CLIENT_BASEDIR - folder that contains the PHP Toolkit and your WSDL
// $USERNAME - variable that contains your Salesforce.com username (must be in the form of an email)
// $PASSWORD - variable that contains your Salesforce.com password
// $TOKEN - variable that contains your Salesforce.com security token

define("SOAP_CLIENT_BASEDIR", "../../soapclient");
require_once (SOAP_CLIENT_BASEDIR.'/SforcePartnerClient.php');

try {
  $mySforceConnection = new SforcePartnerClient();
  $mySoapClient = $mySforceConnection->createConnection(SOAP_CLIENT_BASEDIR.'/partner.wsdl.xml');
  $mylogin = $mySforceConnection->login($USERNAME, $PASSWORD.$TOKEN);

  echo "***** Login Info*****\n";
  print_r($mylogin);
} catch (Exception $e) {
  echo $mySforceConnection->getLastRequest();
  echo $e->faultstring;
}
?>

Sample Login Output

***** Login Info*****
stdClass Object
(
    [metadataServerUrl] => https://na3-api.salesforce.com/services/Soap/m/10.0/470700E300000004wk2
    [passwordExpired] =>
    [serverUrl] => https://na3-api.salesforce.com/services/Soap/u/10.0/470700E400000004wk1
    [sessionId] => 470700D300000005wk1!Y5Jb9LS_b88NQzFFUDY9GnMNdR9uRTNVyEQ88Igpasl0j0KlqAY38ORCJcTqTIXj2veEY_2LyjXMlhtkRbcd5.yUEJsKL44mAJl7PrEhWfLV16FUJj.N1HBN4NiKJ.E.7FmBOwCW    [userId] => 00230000000tH5tAAE
    [userInfo] => stdClass Object
        (
            [accessibilityMode] =>
            [currencySymbol] => $
            [organizationId] => 00C400000005wj1DBA
            [organizationMultiCurrency] =>
            [organizationName] => Salesforce
            [profileId] => 00e40000000luYqBAF
            [roleId] =>
            [userDefaultCurrencyIsoCode] =>
            [userEmail] => myemail@email.com
            [userFullName] => Nick Tran
            [userId] => 00520000000tF3tBAE
            [userLanguage] => en_US
            [userLocale] => en_US
            [userName] => myusername@email.com
            [userTimeZone] => America/Los_Angeles
            [userType] => Standard
            [userUiSkin] => Theme2
        )

)

LoginScopeHeader

Sample LoginScopeHeader Usage

<?php
// SOAP_CLIENT_BASEDIR - folder that contains the PHP Toolkit and your WSDL
// $USERNAME - variable that contains your Salesforce.com username (must be in the form of an email)
// $PASSWORD - variable that contains your Salesforce.ocm password

define("SOAP_CLIENT_BASEDIR", "../../soapclient");
require_once (SOAP_CLIENT_BASEDIR.'/SforcePartnerClient.php');

try {
	$mySforceConnection = new SforcePartnerClient();
	$mySoapClient = $mySforceConnection->createConnection(SOAP_CLIENT_BASEDIR.'/partner.wsdl.xml');
	$header = new LoginScopeHeader('00E200000004wk3EAA');
	$mySforceConnection->setLoginScopeHeader($header);
	$mylogin = $mySforceConnection->login($USERNAME, $PASSWORD);
	
	print_r($mylogin);
	print_r($mySforceConnection->getServerTimestamp());

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

Sample LoginScopeHeader Output

stdClass Object
(
    [metadataServerUrl] => https://na3-api.salesforce.com/services/Soap/m/10.0/473300D300000005wk1
    [passwordExpired] =>
    [serverUrl] => https://na3-api.salesforce.com/services/Soap/u/10.0/473300E300000004wk2
    [sessionId] => 473300E300000003wk1!b2W.jxFyzcBVjxLrixFiiiD3IxdJsu33DMVAv8xZgHqC6eXS8G2iQgiNLqtlDxOX9foby2Fy64.Dbj0d5rc8JfKWelGywpzexprxNVKv7PT3W5gCoOTywk4y3aHzOZzIHxAI2QCW
    [userId] => 03550000000hXLcAAM
)
stdClass Object
(
    [timestamp] => 2008-01-25T00:36:40.939Z
)