Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/280.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用带有PHP Curl的Docusign完整API登录我们的网站,但需要CURLOPT_POSTFIELDS和CURLOPT_URL_Php_Curl_Docusignapi - Fatal编程技术网

使用带有PHP Curl的Docusign完整API登录我们的网站,但需要CURLOPT_POSTFIELDS和CURLOPT_URL

使用带有PHP Curl的Docusign完整API登录我们的网站,但需要CURLOPT_POSTFIELDS和CURLOPT_URL,php,curl,docusignapi,Php,Curl,Docusignapi,我希望我们的客户在我们的网站上点击一个按钮,让它签署Docusign文档,我已经查看了Docusign文档,但没有找到它。有人能告诉我你是怎么做的,或者把我和某个地方联系起来。 我在Stackoverflow上找到的链接都是旧的,URL不再工作了 我想在php中实现这一点,比如curl请求,但我需要Docusign中的CURLOPT_POSTFIELDS和CURLOPT_URL来进行这些请求 像这样 $curl = curl_init(); curl_setopt_array($curl, a

我希望我们的客户在我们的网站上点击一个
按钮,让它签署Docusign文档,我已经查看了Docusign文档,但没有找到它。有人能告诉我你是怎么做的,或者把我和某个地方联系起来。 我在Stackoverflow上找到的链接都是旧的,
URL
不再工作了

我想在php中实现这一点,比如curl请求,但我需要Docusign中的
CURLOPT_POSTFIELDS
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,这里是一些PHP代码,你可以在这里找到完整的例子:(链接到特定文件-)

代码:


下面是一些PHP代码,您可以在这里找到完整的示例:(链接到特定文件-)

代码:


很抱歉,我觉得这个答案没有帮助。您只显示您复制的代码的一部分,因此如果没有链接上的其他部分,我看不出这是如何工作的。你没有解释它,所以我完全不知所措,尤其是
getController()
我看不到它在任何地方被调用。另外
$api\u client=new\DocuSign\eSign\ApiClient($config)应该是
$api\u client=new\DocuSign\eSign\client\ApiClient($config)因为名称空间似乎已更改。以下是我的建议。克隆我展示的整个repo,尝试使用此代码并了解其工作原理。然后在您自己的代码库中实现。这段代码只是一个示例,并不是为了解决您的问题。是否有一个嵌入式版本的Docusign可以与PHP版本(5.6.36)一起使用?我们支持PHP版本5.4及以上。请看这里的源代码-您能否避免我阅读500多个函数,并告诉我如何说明签名者已使用您的Api类对文档进行了签名,谢谢作为我的初始问题陈述,我认为这个答案没有帮助。您只显示您复制的代码的一部分,因此如果没有链接上的其他部分,我看不出这是如何工作的。你没有解释它,所以我完全不知所措,尤其是
getController()
我看不到它在任何地方被调用。另外
$api\u client=new\DocuSign\eSign\ApiClient($config)应该是
$api\u client=new\DocuSign\eSign\client\ApiClient($config)因为名称空间似乎已更改。以下是我的建议。克隆我展示的整个repo,尝试使用此代码并了解其工作原理。然后在您自己的代码库中实现。这段代码只是一个示例,并不是为了解决您的问题。是否有一个嵌入式版本的Docusign可以与PHP版本(5.6.36)一起使用?我们支持PHP版本5.4及以上。请看这里的源代码-您能否避免我阅读500多个函数,并告诉我如何说明签名者已使用您的Api类对文档进行了签名,正如我最初的问题所述
 /**
 * 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;
    }
}