Docusign没有发生数据填充

时间:2017-05-23 04:16:06

标签: docusignapi

因为我是DocuSign Apis的新手。当我从我的代码模板字段中添加动态收件人而不是附加数据并发送给用户时,我在发送电子邮件的同时发送电子邮件时,我遇到了在DocuSign模板中填充predata的问题。请问,有人可以帮我这个吗? / p>

以下是我的代码:

<?php
// Input your info here:
$name = "";
$email = '';
$integratorKey = '';
$password = '';
$email1 = 'testmail@gmail.com';
$templateId = "826e138e-7ad6-4ceb-853b-f545be643527";

$header = "<DocuSignCredentials>
    <Username>" . $email . "</Username>
    <Password>" . $password . "</Password>
    <IntegratorKey>" . $integratorKey . "</IntegratorKey></DocuSignCredentials>";

$url = "https://demo.docusign.net/restapi/v2/login_information";
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, array(
    "X-DocuSign-Authentication: $header"
));
$json_response = curl_exec($curl);
$status = curl_getinfo($curl, CURLINFO_HTTP_CODE);

if ($status != 200)
{
echo "Error  calling webservice, status is:" . $status;
exit(-1);
}

$response = json_decode($json_response, true);
$accountId = $response["loginAccounts"][0]["accountId"];
$baseUrl = $response["loginAccounts"][0]["baseUrl"];
curl_close($curl);

$data = array(
    "accountId" => $accountId,
    "emailSubject" => "DocuSign Templates Webinar - Example 2",
    "emailBlurb" => "Example #2 - Dynamically Populate Form Fields",
    "templateId" => $templateId,
    "templateRoles" => array(
        array(
            "email" => $email,
            "name" => $name,
            "roleName" => "Developer",
            "tabs" => array(
                "textTabs" => array(
                    array(
                        "tabLabel" => "ApplicantSSN",
                        "value" => "test test456456"
                    ) ,
                )
            )
        )
    ) ,
    "status" => "sent"
);

$data_string = json_encode($data);
$curl = curl_init($baseUrl . "/envelopes");
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($curl, CURLOPT_HTTPHEADER, array(
    'Content-Type: application/json',
    'Content-Length: ' . strlen($data_string) ,
    "X-DocuSign-Authentication: $header"
));
$json_response = curl_exec($curl);
echo "<pre>";
print_r($json_response);
$status = curl_getinfo($curl, CURLINFO_HTTP_CODE);

if ($status != 201){
    print_r($json_response);
    echo "\n";
    exit(-1);
}

$response = json_decode($json_response, true);
$envelopeId = $response["envelopeId"];

// To add recipients in docusign
$data1 = json_encode(array(
    "signers" => array(
        array(
            "email" => $email1,
            "name" => 'jkl',
            "roleName" => "Signer",
            "recipientId" => 5000
        )
    )
));
$curl = curl_init($baseUrl . "/envelopes/" . $envelopeId . "/recipients");
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, array(
    'Content-Type: application/json',
    'Content-Length: ' . strlen($data1) ,
    "X-DocuSign-Authentication: $header"
));
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_POSTFIELDS, $data1);
$json_response = curl_exec($curl);
$status = curl_getinfo($curl, CURLINFO_HTTP_CODE);
$response = json_decode($json_response, true);
?>

1 个答案:

答案 0 :(得分:0)

按照以下步骤和上面的代码,它将按预期工作。

1.登录您的模拟账户 2.删除角色的收件人姓名和电子邮件,只留下角色名称。