将电子邮件发送给指定用户Sugar CRM Rest API

时间:2016-12-07 09:08:04

标签: php sugarcrm

正常分配的用户在Sugar CRM中创建/更新潜在客户时会收到电子邮件。 我正在使用REST API在套件CRM中添加/更新潜在客户。我需要向指定的用户发送电子邮件。如何完成?     

$url = "http://{site_url}/service/v4_1/rest.php";
$username = "admin";
$password = "password";

function call($method, $parameters, $url)
{
    ob_start();
    $curl_request = curl_init();

    curl_setopt($curl_request, CURLOPT_URL, $url);
    curl_setopt($curl_request, CURLOPT_POST, 1);
    curl_setopt($curl_request, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0);
    curl_setopt($curl_request, CURLOPT_HEADER, 1);
    curl_setopt($curl_request, CURLOPT_SSL_VERIFYPEER, 0);
    curl_setopt($curl_request, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($curl_request, CURLOPT_FOLLOWLOCATION, 0);

    $jsonEncodedData = json_encode($parameters);

    $post = array(
         "method" => $method,
         "input_type" => "JSON",
         "response_type" => "JSON",
         "rest_data" => $jsonEncodedData
    );

    curl_setopt($curl_request, CURLOPT_POSTFIELDS, $post);
    $result = curl_exec($curl_request);
    curl_close($curl_request);

    $result = explode("\r\n\r\n", $result, 2);
    $response = json_decode($result[1]);
    ob_end_flush();

    return $response;
}

$login_parameters = array(
     "user_auth" => array(
          "user_name" => $username,
          "password" => md5($password),
          "version" => "1"
     ),
     "application_name" => "RestTest",
     "name_value_list" => array(),
);

$login_result = call("login", $login_parameters, $url);


$session_id = $login_result->id;

$set_entry_parameters = array(
     "session" => $session_id,
     "module_name" => "Leads",


     "name_value_list" => array(

          array("firstnamename" => "name", "email1" => "email","assigned_user_id"=>"xxxxx-xxxxx-xx-x-xxx"),
     ),
);

$set_entry_result = call("set_entry", $set_entry_parameters, $url);


?>

我可以更新记录。我需要将电子邮件发送到指定的用户ID。

1 个答案:

答案 0 :(得分:0)

看起来它是自6.5版本以来Sugar API中的已知错误(尚未更正)。

Creating a new Lead via the API not sending email Version 6.5.16 (Build 1082)

Defect 68115: Cases created or updated and assigned via REST API doesn't send out a notification

在原始论坛帖子中,一个人建议使用逻辑钩子作为解决方法。我知道逻辑钩子存在但从未使用它们,但我相信它是一条尝试的路径。

祝你好运!