我只是在努力让这段代码工作时写信给你。我可以根据需要从命令行调用 api。在将它转换为 PHP 可读的 curl 后,我尝试从 php 函数调用它,它似乎发送但我只是得到一个空数组作为响应。它非常混乱,因为我之前从 api 收到有效的错误消息作为响应。我将列出 php 和 html 表单的代码。
<?php
$name = $_POST['testName'];
$email = $_POST['testEmail'];
$file = $_FILES['testFile'];
$url = $_POST['testURL'];
runSend($file, $name, $email);
function runSend($file, $name, $email){
echo "Success, message sent";
echo $file;
echo $name;
echo $email;
echo $url;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://api.boldsign.com/v1/document/send');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
$post = array(
'Title' => 'Commercial Agreement',
'Message' => 'Terms, purpose and duration of agreement ',
'UseTextTags' => 'true',
'EnableSigningOrder' => 'false',
'Signers[0][Name]' => 'Example Name',
'Signers[0][EmailAddress]' => '[email protected]',
'Signers[0][SignerOrder]' => '0',
'Signers[0][FormFields][0][FieldType]' => 'Signature',
'Signers[0][FormFields][0][Name]' => 'sign_field',
'Signers[0][FormFields][0][PageNumber]' => '1',
'Signers[0][FormFields][0][Bounds][X]' => '50',
'Signers[0][FormFields][0][Bounds][Y]' => '50',
'Signers[0][FormFields][0][Bounds][Width]' => '200',
'Signers[0][FormFields][0][Bounds][Height]' => '30',
'Signers[0][FormFields][0][IsRequired]' => 'true',
'Files' => new CURLFILE($file)
);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
$headers = array();
$headers[] = 'X-Api-Key: EXAM76242$PLEA32PIK555EY';
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($ch);
if (curl_errno($ch)) {
echo 'Error:' . curl_error($ch);
}
curl_close($ch);
<form action="/wp-content/themes/hello-theme-child-master/send-test-file.php" method="post" enctype="multipart/form-data">
name:
<input type="text" id="testName" name="testName" value="[7401]"><br>
email
<input type="text" id="testEmail" name="testEmail" value="testEmail"><br>
Select pdf to upload:
<input type="file" name="testFile" id="testFile">
<input type="text" id="testURL" name="testURL" value="[e2pdf-download id="31" output='url']"><br>
<input type="submit" value="Send File" name="submit">
</form>
我曾多次尝试重构代码,但坦率地说,我很难过。