2013-06-19 108 views
2

我正在關注docusign的教程,使用他們的PHP API創建一個信封。 Tutorialis在這裏找到:http://www.docusign.com/developer-center/quick-start/request-signaturesDocusign教程 - PHP API cURL錯誤 - 「緩衝區不能爲空」

我複製的代碼,並下載示例文件,我現在得到這樣的響應: 「錯誤碼」:「UNSPECIFIED_ERROR」,「消息」:「緩衝區不能爲空\ r \ n參數名:緩衝區」

我認爲錯誤可能與本節:

$requestBody = "\r\n" 
."\r\n" 
."--myboundary\r\n" 
."Content-Type: application/json\r\n" 
."Content-Disposition: form-data\r\n" 
."\r\n" 
."$data_string\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"; 

的問題,我認爲,是$ data_string沒有在他們的榜樣任何地方所定義。有一個數據定義:

$data = "{ 
\"emailBlurb\":\"This comes from PHP\", 
\"emailSubject\":\"API Signature Request\", 
\"documents\":[ 
{ 
\"documentId\":\"1\", 
\"name\":\"document.pdf\" 
} 
], 
\"recipients\":{ 
\"signers\":[ 
{ 
\"email\":$email, 
\"name\":$name, 
\"recipientId\":\"1\", 
\"tabs\":{ 
\"signHereTabs\":[ 
{ 
\"xPosition\":\"100\", 
\"yPosition\":\"100\", 
\"documentId\":\"1\", 
\"pageNumber\":\"1\" 
} 
] 
} 
} 
] 
}, 
\"status\":\"sent\" 
}"; 

....但不是$ data_string。

我嘗試使用「TEST」的值$ data_string並獲得:"errorCode": "INVALID_MULTI_PART_REQUEST", "message": "An error was found while parsing the multipart request. The JSON data in the first part of the multi-part request does not match the expected format. The token 'true' was expected but found 'test'."

我再設置的$ data_string爲布爾(TRUE)的值,並得到了以下錯誤消息:errorCode": "INVALID_MULTI_PART_REQUEST", "message": "An error was found while parsing the multipart request. The JSON data in the first part of the multi-part request does not match the expected format. "

任何幫助解決這一問題,非常感謝。

回答

0

所有你需要做的是改變$ data_string到$代碼中的數據...

感謝趕上這一點,我已經更新了請求籤名頁面上的要點時,應該現在的工作。

1

是的,這是一個錯誤。我正在創建一個從該示例代碼派生的明智的PHP類文件。這是一個源自該代碼的類,它的工作原理和清潔程度較高:https://github.com/sylnsr/esign-samples/tree/master/docusign/php - 如果您有興趣探索DocuSign以外的其他產品,請隨時登錄該項目,以便其他供應商隨時獲取其他樣品如我將在下一步工作的RightSignature。

+0

P.S.我還添加了一個檢查以確保文檔ID是一個GUID或一個整數。我注意到,如果您嘗試在JSON中爲「recipientId」使用類似「收件人1」的服務,則服務會返回錯誤消息 –

+0

FYI DocuSign爲其REST API發佈了Java和PHP客戶端庫。看到這裏:https://github.com/docusign/eSignPHPLib – Ergin