2013-11-22 99 views
0

我正在使用docusign rest api。我正在嘗試創建一個模板,然後使用嵌入式發送。嵌入式發送角色名稱docusign

這裏是我的代碼:

創建模板:

$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_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) { 
    $status = 'notok'; 
} 

$response = json_decode($json_response, true); 

if((isset($response['errorCode'])) && ($response['errorCode'] == 'USER_LACKS_PERMISSIONS')) { 
    echo $msg = 'This user lacks sufficient permissions'; 
    $_SESSION['msg_frm_apd'] = $msg; 

} 



$accountId = $response["loginAccounts"][0]["accountId"]; 
$baseUrl = $response["loginAccounts"][0]["baseUrl"]; 
curl_close($curl); 

$template_name = "template_" . time(); 

$data = "{ 
    \"emailBlurb\":\"String content\", 
\"emailSubject\":\"String content\", 
    \"documents\": [{ 
\"documentId\": \"1\", 
\"name\": \"document.pdf\" 
}], 
\"recipients\": { 
\"signers\": [{ 
\"recipientId\": \"1\", 
\"roleName\": \"Signer 1\" 
}] 
}, 
\"envelopeTemplateDefinition\": { 
\"description\": \"Description\", 
\"name\": \"$template_name\" 
} 
}"; 





$file_contents = file_get_contents("uploads/envelopes/" . $file_name); 

$requestBody = "\r\n" 
."\r\n" 
."--myboundary\r\n" 
."Content-Type: application/json\r\n" 
."Content-Disposition: form-data\r\n" 
."\r\n" 
."$data\r\n" 
."--myboundary\r\n" 
."Content-Type:application/pdf\r\n" 
."Content-Disposition: file; filename=\」document.pdf\"; documentid=1 \r\n" 
."\r\n" 
."$file_contents\r\n" 
."--myboundary--\r\n" 
."\r\n"; 


$url = "https://demo.docusign.net/restapi/v2/accounts/376082/templates"; 


$curl = curl_init($url); 
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); 
curl_setopt($curl, CURLOPT_POST, true); 
curl_setopt($curl, CURLOPT_POSTFIELDS, $requestBody);                 
curl_setopt($curl, CURLOPT_HTTPHEADER, array(                   
    'Content-Type: multipart/form-data;boundary=myboundary', 
    'Content-Length: ' . strlen($requestBody), 
    "X-DocuSign-Authentication: $header")                  
); 

$json_response = curl_exec($curl); 
$response = json_decode($json_response, true); 


$status = curl_getinfo($curl, CURLINFO_HTTP_CODE); 
if ($status != 201) { 
    echo "error calling webservice, status is:" . $status . "\nerror text is --> "; 
    print_r($json_response); echo "\n"; 
    exit(-1); 
} 

$response = json_decode($json_response, true); 

嵌入式發送:

$templateId = $response['templateId']; // provide a valid templateId of a template in your account 

    $clientUserId = "1234"; 
    $templateRoleName = "Signer 1"; 

$data = array("accountId" => $accountId, 
    "emailSubject" => "DocuSign API - Embedded Sending Example", 
    "templateId" => $templateId, 
    "templateRoles" => array(
     array("roleName" => $templateRoleName, "email" => $recipient_email, "name" => $recipient_name, "clientUserId" => $clientUserId)), 
    "status" => "created");                  



    $data_string = json_encode($data); 
    $curl = curl_init($baseUrl . "/envelopes"); 
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); 
    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")                docusign  
); 

    $json_response = curl_exec($curl); 
    $status = curl_getinfo($curl, CURLINFO_HTTP_CODE); 
    if ($status != 201) { 
    echo "error calling webservice, status is:" . $status . "\nerror text is --> "; 
    print_r($json_response); echo "\n"; 
    exit(-1); 
    } 

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

    //--- display results 
// echo "Envelope created! Envelope ID: " . $envelopeId . "\n"; 

    ///////////////////////////////////////////////////////////////////////////////////////////////// 
    // STEP 3 - Get the Embedded Sending View (aka the "tag-and-send" view) 
    ///////////////////////////////////////////////////////////////////////////////////////////////// 
    /*$data = array("returnUrl" => "http://www.docusign.com/devcenter");*/ 
    $returnUrl = $SITE_URL . "/docusign_return.php"; 
    $data = array("returnUrl" => $returnUrl);                  
    $data_string = json_encode($data);                     
    $curl = curl_init($baseUrl . "/envelopes/$envelopeId/views/sender"); 
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); 
    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); 
    $response = json_decode($json_response, true); 
    $status = curl_getinfo($curl, CURLINFO_HTTP_CODE); 
    if ($status != 201) { 
    echo "error calling webservice, status is:" . $status . "\nerror text is --> "; 
    print_r($json_response); echo "\n"; 
    exit(-1); 
    } 

    $url = urlencode($response["url"]); 

當我在上面的鏈接點擊,我得到一個頁面,我可以標記和發送文檔。在此頁面中有一個電子郵件地址 字段,該字段將自動填入$recipient_email。但問題是郵件不會收到收件人的電子郵件地址。謝謝。(我也沒有收到任何錯誤信息)。

回答

1

您的代碼沒有問題,並且按預期完美工作。我可以告訴你使用DocuSign的API Walkthroughs的示例代碼。

如果你說的一切工作正常,沒有錯誤,但是在導航到嵌入式發送URL併發送文檔進行簽名之後,收件人未收到電子郵件,我將檢查安全軟件,垃圾郵件/垃圾郵件過濾器,防火牆等等。 DocuSign服務的使用非常廣泛,如果電子郵件沒有出現在簽名請求中,它會很快出現一個很大的臭味,最重要的是,我只是做了一個測試,而且我的電子郵件發送很順利。

如上所述,如果您確定電子郵件地址是正確的,並且您通過用戶界面點擊了SEND按鈕,我會檢查安全軟件,垃圾郵件/垃圾郵件過濾器,防火牆以及其他可能會停止來自你方的電子郵件。

1

解決電子郵件傳遞問題的另一個建議:使用DocuSign Connect。如果您的帳戶配置正確,您可以啓用Connect並使用連接日誌來檢測收件人電子郵件是否無法投遞(即,如果DocuSign在發送到該地址時收到「退回」)。

  • 在DocuSign中創建自定義連接配置,如本指南中所述:http://www.docusign.com/sites/default/files/DocuSign_Connect_Service_Guide.pdf

  • 在連接配置您創建的,您可以指定任何URL作爲URL發佈到 - 你試圖爲這個測試做的一切都是爲了使連接發送通知發送的「收件人「事件和」收件人傳送失敗「事件(併爲其發送的通知創建日誌條目) - 指定的端點將無法配置爲接收/處理連接消息並不重要。

  • 在您創建的,一定要選擇我在這裏強調了方案的連接配置(如前所述,你可以使用任何URL - 我剛好選擇了google.com):Connect Configuration settings

  • 如上所述創建並保存連接配置後,請完成您在問題中描述的過程以創建/發送信封。

  • 發送信封后,請以管理員身份登錄到DocuSign Web控制檯並查看連接日誌條目。 (即,導航到首選項>>連接>>日誌Connect Logs link

  • 你應該看到日誌和/或「收件人傳遞失敗」事件的每個「發送者」,因爲您創建的時間到發生列出的條目/啓用連接配置Connect log entries

  • 檢查日誌條目的內容應允許您確定DocuSign是否成功發送收件人電子郵件,以及收件人電子郵件是否反彈爲無法投遞。

如果日誌條目指示DocuSign正在發送收件人電子郵件並且未指明任何退回,那麼電子郵件客戶端可能會阻止收件人接收電子郵件(如Ergin建議的那樣在他的回答中)。

相關問題