SugarCRM can’t talk to PHP 5 native SOAP libraries in WSDL mode, so connect without it. Find below a series of queries that each worked for me, all just dumped here in succession, don’t try to run this whole piece of code – it is intended as a series of examples. Use each line and then var_dump($response) to see what’s happening.
// set up options array
$options = array(
"location" => 'http://192.168.1.129/aeat/spm/crm/soap.php',
"uri" => 'http://www.sugarcrm.com/sugarcrm',
"trace" => 1
);
// connect to soap server
$client = new SoapClient(NULL, $options);
// look what modules sugar exposes
$response = $client->get_available_modules($session_id);
// look in more detail at the fields in the Accounts module
$response = $client->get_module_fields($session_id, 'Accounts');
// look for a particular account name and then get its ID
$response = $client->get_entry_list($session_id, 'Accounts', 'name like "%LornaJane%"');
$account_id = $response->entry_list[0]->id;
// create a new account record and grab its ID
$response = $client->set_entry($session_id, 'Accounts', array(
array("name" => 'name', "value" => 'New Company')
));
$account_id = $response->id;
// create a new contact record, assigned to this account, and grab the contact ID
$response = $client->set_entry($session_id, 'Contacts', array(
array("name" => 'first_name',"value" => 'Geek'),
array("name" => 'last_name',"value" => 'Smith'),
array("name" => 'email1',"value" => '[email protected]'),
array("name" => 'account_id',"value" => $account_id)
));
$contact_id = $response->id;
I hope this helps – if you have anything to add, or would like to post some examples, please do :)
