Skip to content

Instantly share code, notes, and snippets.

@omidnasri
Created May 26, 2019 11:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save omidnasri/0063a74b88235aa75f230a1812c77713 to your computer and use it in GitHub Desktop.
Save omidnasri/0063a74b88235aa75f230a1812c77713 to your computer and use it in GitHub Desktop.
A simple solution to find person by ID.
<?php
/**
* Target: FindPersonById
*
* Authors: Omid Nasri
*
* Description: A simple solution to find person by ID.
*
* Version: 1.0
*/
try
{
// Enter the field with the username and password that has the necessary permission to find the person.
$username = 'admin';
$password = 'admin';
// Replace <url> keyword to your CRM host address.
$url = 'http(s)://<url>/services/api/IPerson.svc?wsdl';
// Create new instance of SoapClient to call FindPersonById method.
$soapClient = new SoapClient( $url );
$params = array(
'username' => $username,
'password' => $password,
'personId' => '7752d1da-5699-4226-b8a1-1ee6d20b0fbf'
);
// Calling the FindPersonById method.
$Result = $soapClient->FindPersonById($params);
// Checked that the operation was successful or not.
if ($Result->FindPersonByIdResult->Success)
{
//Converting Object to JSON type then print output vlaue.
echo json_encode($Result, JSON_UNESCAPED_UNICODE);
}
else
echo $Result->FindPersonByIdResult->Message;
}
catch ( Exception $e )
{
// Print exception message
echo $e->getMessage();
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment