Created
July 2, 2010 04:46
-
-
Save tsnoad/460942 to your computer and use it in GitHub Desktop.
soap interface to sugarcrm
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 | |
// set up options array | |
$options = array( | |
"location" => 'http://192.168.25.28/soap.php', | |
"uri" => 'http://192.168.25.28', | |
"trace" => 2 | |
); | |
// connect to soap server | |
$client = new SoapClient(NULL, $options); | |
//user authentication array | |
$user_auth = array( | |
"user_name" => "admin", | |
"password" => md5("resources"), | |
"version" => ".01" | |
); | |
$response = $client->login($user_auth, "test"); | |
//get the session id from the login | |
$session_id = $response->id; | |
var_dump($response); | |
/* | |
// 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'); | |
*/ | |
/* var_dump($response); */ | |
// look for a particular account name and then get its ID | |
$response = $client->get_entry_list($session_id, 'Accounts', "name like '%foo%'"); | |
/* $account_id = $response->entry_list[0]->id; */ | |
var_dump($response); | |
/* | |
// 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" => 'Foo'), | |
array("name" => 'last_name',"value" => 'Foobarson'), | |
array("name" => 'email1',"value" => '[email protected]'), | |
array("name" => 'account_id',"value" => $account_id) | |
)); | |
$contact_id = $response->id; | |
*/ | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment