Skip to content

Instantly share code, notes, and snippets.

@jmertic
Created September 30, 2013 13:08
Show Gist options
  • Save jmertic/6763561 to your computer and use it in GitHub Desktop.
Save jmertic/6763561 to your computer and use it in GitHub Desktop.
<?php
//set up options array
$options = array(
"location" => 'https://site14/sugar6/soap.php',
"uri" => 'http://www.sugarcrm.com/sugarcrm',
"trace" => 1
);
//user authentication array
$user_auth = array(
"user_name" => 'Iusein',
"password" => MD5('pdgrg')
);
$client = new SoapClient(NULL, $options);
$response = $client->login($user_auth,'admin');
$session_id = $response->id;
echo $user_guid = $client->get_user_id($session_id);
try {
$info = $client->set_entry(
$session_id,
'Contacts',
array(
array('name' => 'first_name', 'value' => 'Foo'),
array('name' => 'last_name', 'value' => 'Bar'),
array('name' => 'description', 'value' => 'This is a contact created from a SOAP web services call'),
)
);
}
catch (SoapFault $fault) {
die("Sorry, the service returned the following ERROR: ".$fault->faultcode."-".$fault->faultstring.".");
}
$contactId = $info->id;
echo "Created Contact ID {$contactId}n";
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment