<?php
$url = "https://yoursuiteinstall.com/service/v4_1/rest.php";
function restRequest($method, $arguments){
global $url;
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$post = array(
"method" => $method,
"input_type" => "JSON",
"response_type" => "JSON",
"rest_data" => json_encode($arguments),
);
curl_setopt($curl, CURLOPT_POSTFIELDS, $post);
$result = curl_exec($curl);
curl_close($curl);
return json_decode($result,1);
}
function createlead($firstname,$lastname,$email,$phone,$howtheyheard)
{
$userAuth = array(
'user_name' => 'username',
'password' => md5('password'),
);
$appName = 'My SuiteCRM REST Client';
$nameValueList = array();
$args = array(
'user_auth' => $userAuth,
'application_name' => $appName,
'name_value_list' => $nameValueList
);
$result = restRequest('login',$args);
echo "<pre>";
print_r($result);
$sessId = $result['id'];
$entryArgs = array(
'session' => $sessId, // Session id - retrieved from login call
'module_name' => 'Leads', // Module to get_entry_list for
'name_value_list ' => array(
'assigned_user_id' => '592bb305-8073-9ddd-2214-58c1c81f0245',
'status' => 'New',
'first_name' => $firstname,
'last_name' => $lastname,
'email1' => $email,
'phone_home' => $phone,
'web_how_they_heard_c' => $howtheyheard,
));
$result = restRequest('set_entry',$entryArgs);
echo "<pre>";
print_r($result);
}
createlead("Bill","Lee","billlee@test2.com","55555555555","Online rest call");
?>
Can any of you advise me why this created 2 entries with the same information when i run this rest call. Anyone can test this just change your parameters. $url, $username, $password and it should work for you.