Created
June 28, 2012 19:27
-
-
Save sugarknowledge/3013351 to your computer and use it in GitHub Desktop.
PHP Example using NuSOAP with the v4 SOAP API to retrieve a list of records with get_entry_list
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Array | |
( | |
[result_count] => 2 | |
[total_count] => 200 | |
[next_offset] => 2 | |
[entry_list] => Array | |
( | |
[0] => Array | |
( | |
[id] => 18124607-69d1-b158-47ff-4f7cb69344f7 | |
[module_name] => Leads | |
[name_value_list] => Array | |
( | |
[0] => Array | |
( | |
[name] => id | |
[value] => 18124607-69d1-b158-47ff-4f7cb69344f7 | |
) | |
[1] => Array | |
( | |
[name] => name | |
[value] => Bernie Worthey | |
) | |
[2] => Array | |
( | |
[name] => title | |
[value] => Senior Product Manager | |
) | |
) | |
) | |
[1] => Array | |
( | |
[id] => 1cdfddc1-2759-b007-8713-4f7cb64c2e9c | |
[module_name] => Leads | |
[name_value_list] => Array | |
( | |
[0] => Array | |
( | |
[name] => id | |
[value] => 1cdfddc1-2759-b007-8713-4f7cb64c2e9c | |
) | |
[1] => Array | |
( | |
[name] => name | |
[value] => Bobbie Kohlmeier | |
) | |
[2] => Array | |
( | |
[name] => title | |
[value] => Director Operations | |
) | |
) | |
) | |
) | |
[relationship_list] => Array | |
( | |
) | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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']; | |
//get list of records ------------------------------------------------------- | |
$get_entry_list_parameters = array( | |
//session id | |
'session' => $session_id, | |
//The name of the module from which to retrieve records | |
'module_name' => 'Leads', | |
//The SQL WHERE clause without the word "where". | |
'query' => "", | |
//The SQL ORDER BY clause without the phrase "order by". | |
'order_by' => "", | |
//The record offset from which to start. | |
'offset' => '0', | |
//Optional. A list of fields to include in the results. | |
'select_fields' => array( | |
'id', | |
'name', | |
'title', | |
), | |
/* | |
A list of link names and the fields to be returned for each link name. | |
Example: 'link_name_to_fields_array' => array(array('name' => 'email_addresses', 'value' => array('id', 'email_address', 'opt_out', 'primary_address'))) | |
*/ | |
'link_name_to_fields_array' => array( | |
), | |
//The maximum number of results to return. | |
'max_results' => '2', | |
//To exclude deleted records | |
'deleted' => '0', | |
//If only records marked as favorites should be returned. | |
'Favorites' => false, | |
); | |
$get_entry_list_result = $client->call('get_entry_list', $get_entry_list_parameters); | |
echo '<pre>'; | |
print_r($get_entry_list_result); | |
echo '</pre>'; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment