按钮,为了让它签署文档,我已经查看了Docusign,但没有找到它。有人能给我解释一下你是怎么做的还是把我联系到什么地方。我在Stackoverflow上找到的链接都是旧的,urls不再工作了。我想在php中这样做,就像curl请求一样,但是我需要CURLOPT_POSTFIELDS和Docusign的CURLOPT_URL来进行这些请求。像这">
我希望我们的客户在我们的网站上循环一个<input/>
按钮,为了让它签署文档,我已经查看了Docusign,但没有找到它。有人能给我解释一下你是怎么做的还是把我联系到什么地方。我在Stackoverflow上找到的链接都是旧的,urls
不再工作了。
我想在php中这样做,就像curl请求一样,但是我需要CURLOPT_POSTFIELDS
和Docusign的CURLOPT_URL
来进行这些请求。
像这样
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://docisign.com/v2.1/documents/{documentId}/users/{userId}/operations", //Just supposing
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => false,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, //Just supposing
CURLOPT_CUSTOMREQUEST => "POST", //Just supposing
CURLOPT_POSTFIELDS => "{
\"type\": \"accept\",
\"members\": [
\"/members/" . $idMember . "\" //Just supposing
],
}",
CURLOPT_HTTPHEADER => array(
"Authorization: API KEY ??", //Just supposing
"Content-Type: application/json"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
感谢任何有更多关于这个主题的信息的人。
编辑:我正在使用PHP5.6
发布于 2019-10-10 08:58:26
下面是一些PHP代码,您可以在这里找到完整的示例:https://github.com/docusign/eg-03-php-auth-code-grant (链接到特定文件- https://github.com/docusign/eg-03-php-auth-code-grant/blob/master/src/EG001EmbeddedSigning.php)
代码:
/**
* Do the work of the example
* 1. Create the envelope request object
* 2. Send the envelope
* 3. Create the Recipient View request object
* 4. Obtain the recipient_view_url for the signing ceremony
* @param $args
* @return array ['redirect_url']
* @throws \DocuSign\eSign\ApiException for API problems and perhaps file access \Exception too.
*/
# ***DS.snippet.0.start
private function worker($args)
{
$envelope_args = $args["envelope_args"];
# 1. Create the envelope request object
$envelope_definition = $this->make_envelope($envelope_args);
# 2. call Envelopes::create API method
# Exceptions will be caught by the calling function
$config = new \DocuSign\eSign\Configuration();
$config->setHost($args['base_path']);
$config->addDefaultHeader('Authorization', 'Bearer ' . $args['ds_access_token']);
$api_client = new \DocuSign\eSign\Client\ApiClient($config);
$envelope_api = new \DocuSign\eSign\Api\EnvelopesApi($api_client);
$results = $envelope_api->createEnvelope($args['account_id'], $envelope_definition);
$envelope_id = $results->getEnvelopeId();
# 3. Create the Recipient View request object
$authentication_method = 'None'; # How is this application authenticating
# the signer? See the `authenticationMethod' definition
# https://developers.docusign.com/esign-rest-api/reference/Envelopes/EnvelopeViews/createRecipient
$recipient_view_request = new \DocuSign\eSign\Model\RecipientViewRequest([
'authentication_method' => $authentication_method,
'client_user_id' => $envelope_args['signer_client_id'],
'recipient_id' => '1',
'return_url' => $envelope_args['ds_return_url'],
'user_name' => $envelope_args['signer_name'], 'email' => $envelope_args['signer_email']
]);
# 4. Obtain the recipient_view_url for the signing ceremony
# Exceptions will be caught by the calling function
$results = $envelope_api->createRecipientView($args['account_id'], $envelope_id,
$recipient_view_request);
return ['envelope_id' => $envelope_id, 'redirect_url' => $results['url']];
}
/**
* Creates envelope definition
* @param $args parameters for the envelope:
* signer_email, signer_name, signer_client_id
* @return mixed -- returns an envelope definition
*/
private function make_envelope($args)
{
# document 1 (pdf) has tag /sn1/
#
# The envelope has one recipient.
# recipient 1 - signer
#
# Read the file
$demo_docs_path = __DIR__ . '/../public/demo_documents/';
$content_bytes = file_get_contents($demo_docs_path . $GLOBALS['DS_CONFIG']['doc_pdf']);
$base64_file_content = base64_encode($content_bytes);
# Create the document model
$document = new \DocuSign\eSign\Model\Document([ # create the DocuSign document object
'document_base64' => $base64_file_content,
'name' => 'Example document', # can be different from actual file name
'file_extension' => 'pdf', # many different document types are accepted
'document_id' => 1 # a label used to reference the doc
]);
# Create the signer recipient model
$signer = new \DocuSign\eSign\Model\Signer([ # The signer
'email' => $args['signer_email'], 'name' => $args['signer_name'],
'recipient_id' => "1", 'routing_order' => "1",
# Setting the client_user_id marks the signer as embedded
'client_user_id' => $args['signer_client_id']
]);
# Create a sign_here tab (field on the document)
$sign_here = new \DocuSign\eSign\Model\SignHere([ # DocuSign SignHere field/tab
'anchor_string' => '/sn1/', 'anchor_units' => 'pixels',
'anchor_y_offset' => '10', 'anchor_x_offset' => '20'
]);
# Add the tabs model (including the sign_here tab) to the signer
# The Tabs object wants arrays of the different field/tab types
$signer->settabs(new \DocuSign\eSign\Model\Tabs(['sign_here_tabs' => [$sign_here]]));
# Next, create the top level envelope definition and populate it.
$envelope_definition = new \DocuSign\eSign\Model\EnvelopeDefinition([
'email_subject' => "Please sign this document sent from the PHP SDK",
'documents' => [$document],
# The Recipients object wants arrays for each recipient type
'recipients' => new \DocuSign\eSign\Model\Recipients(['signers' => [$signer]]),
'status' => "sent" # requests that the envelope be created and sent.
]);
return $envelope_definition;
}
# ***DS.snippet.0.end
/**
* Show the example's form page
*/
private function getController()
{
if (ds_token_ok()) {
$basename = basename(__FILE__);
$GLOBALS['twig']->display('eg001_embedded_signing.html', [
'title' => "Embedded Signing Ceremony",
'source_file' => $basename,
'source_url' => $GLOBALS['DS_CONFIG']['github_example_url'] . $basename,
'documentation' => $GLOBALS['DS_CONFIG']['documentation'] . $this->eg,
'show_doc' => $GLOBALS['DS_CONFIG']['documentation'],
'signer_name' => $GLOBALS['DS_CONFIG']['signer_name'],
'signer_email' => $GLOBALS['DS_CONFIG']['signer_email']
]);
} else {
# Save the current operation so it will be resumed after authentication
$_SESSION['eg'] = $GLOBALS['app_url'] . 'index.php?page=' . $this->eg;
header('Location: ' . $GLOBALS['app_url'] . 'index.php?page=must_authenticate');
exit;
}
}
https://stackoverflow.com/questions/58320213
复制