Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save sugarknowledge/3188258 to your computer and use it in GitHub Desktop.

Select an option

Save sugarknowledge/3188258 to your computer and use it in GitHub Desktop.
PHP Example using NuSOAP with the v4 SOAP API to retrieve leads related to a specific target list with get_relationships
Array
(
[entry_list] => Array
(
[0] => Array
(
[id] => 117c26c0-11d4-7b8b-cb8f-4f7cb6823dd8
[module_name] => Leads
[name_value_list] => Array
(
[0] => Array
(
[name] => id
[value] => 117c26c0-11d4-7b8b-cb8f-4f7cb6823dd8
)
[1] => Array
(
[name] => first_name
[value] => Diane
)
[2] => Array
(
[name] => last_name
[value] => Mckamey
)
)
)
[1] => Array
(
[id] => 142faeef-1a19-b53a-b780-4f7cb600c553
[module_name] => Leads
[name_value_list] => Array
(
[0] => Array
(
[name] => id
[value] => 142faeef-1a19-b53a-b780-4f7cb600c553
)
[1] => Array
(
[name] => first_name
[value] => Leonor
)
[2] => Array
(
[name] => last_name
[value] => Reser
)
)
)
)
[relationship_list] => Array
(
)
)
<?php
$url = "http://{site_url}/service/v4/soap.php?wsdl";
$username = "admin";
$password = "password";
//require NuSOAP
require_once("./nusoap/lib/nusoap.php");
//retrieve WSDL
$client = new nusoap_client($url, 'wsdl');
//display errors
$err = $client->getError();
if ($err)
{
echo '<h2>Constructor error</h2><pre>' . $err . '</pre>';
echo '<h2>Debug</h2><pre>' . htmlspecialchars($client->getDebug(), ENT_QUOTES) . '</pre>';
exit();
}
//login -------------------------------------------------------
$login_parameters = array(
'user_auth' => array(
'user_name' => $username,
'password' => md5($password),
'version' => '1'
),
'application_name' => 'SoapTest',
'name_value_list' => array(
),
);
$login_result = $client->call('login', $login_parameters);
/*
echo '<pre>';
print_r($login_result);
echo '</pre>';
*/
//get session id
$session_id = $login_result['id'];
//retrieve related list -------------------------------------------------------------------------------
$get_relationships_parameters = array(
'session'=>$session_id,
//The name of the module from which to retrieve records.
'module_name' => 'ProspectLists',
//The ID of the specified module bean.
'module_id' => '76d0e694-ef66-ddd5-9bdf-4febd3af44d5',
//The relationship name of the linked field from which to return records.
'link_field_name' => 'leads',
//The portion of the WHERE clause from the SQL statement used to find the related items.
'related_module_query' => '',
//The related fields to be returned.
'related_fields' => array(
'id',
'first_name',
'last_name',
),
//For every related bean returned, specify link field names to field information.
'related_module_link_name _to_fields_array' => array(
),
//To exclude deleted records
'deleted'=> '0',
//order by
'order_by' => '',
//offset
'offset' => 0,
//limit
'limit' => 5,
);
$get_relationships_result = $client->call("get_relationships", $get_relationships_parameters);
echo "<pre>";
print_r($get_relationships_result);
echo "</pre>";
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment