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
alivepjcalivepjc 

getUserInfo()

Hi,

Anybody has sample code on the getUserInfo() call? I am trying to get the userId from the user logged in the current session.

Thanks!
Eugene KapustinEugene Kapustin
Hello alivepjc,

Here is sample (insert your username, password and user id):


/* Create SF SOAP client */
$oClient = new SoapClient( "enterprise.wsdl", array('trace' => true ) );

/* Set Login properties */
$aLogin = array(
"username" => "your username",
"password" => "your password"
);

/* Login to SF SOAP API */
$oLoginResult = $oClient->login( $aLogin );

print "
";
print_r( $oLoginResult );
print "
";

/* This code is requred */
$oClient->__setLocation( $oLoginResult->result->serverUrl );

/*
* Create SoapHeader object to support authorization for feature requests
*/
$oHeaders[0] = new SoapHeader(
"urn:enterprise.soap.sforce.com",
"SessionHeader",
(object)array( "sessionId" => (string)$oLoginResult->result->sessionId ),
0
);

$aQOptions = array();

$aRequest = array(
(object)array(
"Id" => "Your User ID"
)
);

$oRes = $oClient->__soapCall( 'getUserInfo', $aRequest, $aQOptions, $oHeaders );

print "
";
print_r( $oRes );
print "
";

?>

Thank you,
Eugene Kapustin

Message Edited by Eugene Kapustin on 11-17-2005 03:01 PM

Message Edited by Eugene Kapustin on 11-17-2005 03:09 PM

Message Edited by Eugene Kapustin on 11-17-2005 03:09 PM

Message Edited by Eugene Kapustin on 11-17-2005 03:10 PM