首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
社区首页 >问答首页 >用PHP在我们的网站上使用Docusign进行签名,但需要CURLOPT_POSTFIELDS和CURLOPT_URL

用PHP在我们的网站上使用Docusign进行签名,但需要CURLOPT_POSTFIELDS和CURLOPT_URL
EN

Stack Overflow用户
提问于 2019-10-10 01:55:05
回答 1查看 468关注 0票数 1

我希望我们的客户在我们的网站上循环一个<input/>按钮,为了让它签署文档,我已经查看了Docusign,但没有找到它。有人能给我解释一下你是怎么做的还是把我联系到什么地方。我在Stackoverflow上找到的链接都是旧的,urls不再工作了。

我想在php中这样做,就像curl请求一样,但是我需要CURLOPT_POSTFIELDS和Docusign的CURLOPT_URL来进行这些请求。

像这样

代码语言:javascript
运行
AI代码解释
复制
$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

EN

回答 1

Stack Overflow用户

发布于 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)

代码:

代码语言:javascript
运行
AI代码解释
复制
 /**
 * 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;
    }
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/58320213

复制
相关文章
java中获取当前时间_java如何获得当前时间
获取标准时间可以使用 System.currentTimeMillis() 方法来获取,此方法优势是不受时区的影响,但是得到结果是时间戳的格式,如:
全栈程序员站长
2022/10/04
4.6K0
java中获取当前时间_java如何获得当前时间
Jackson 动态过滤属性,编程式过滤对象中的属性
场景:有时候我们做系统的时候,比如两个请求,返回同一个对象,但是需要的返回字段并不相同。
全栈程序员站长
2022/07/20
4.6K0
Swift:属性访问类别
版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
菜菜不吃蔡
2019/11/03
7930
Swift:属性访问类别
如何从JavaScript对象中删除属性?
在使用 JavaScript 中的对象时,你可能会遇到需要从对象中完全删除属性的情况。为实现这一点可以有好几个选择:
疯狂的技术宅
2021/04/01
12.8K0
获得当前cpu中的进程信息
[root@localhost ~]# cat /proc/sched_debug Sched Debug Version: v0.09, 2.6.33-rc1 #1 now at 18954381.354499 msecs   .jiffies : 18654381   .sysctl_sched_latency : 10.000000   .sysctl_sched_min_granularity
用户3765803
2019/03/05
1.7K0
Slice如何从网络消费数据中获得商机
和大多人一样,斯科特·布雷迪(Scott Brady)通过谷歌购物(Google Shopping)和亚马逊生鲜(Amazon Fresh)等各种网站,从网上购买的东西越来越多。 但即使亚马逊已创立近20年,对购买者是谁、购买了什么产品、怎样购买和购买原因的追踪,依然很难筛选出一个结果来。我们对消费者行为到底都了解些什么?多数消费者行为都是从小规模消费者群体推断、预测或推测的。当市场营销人员从数据经纪商处购买信息时,很多信息都陈旧不堪或者不完整。 这就是布雷迪的网购数据分析公司Slice为何如此激发人兴趣的
大数据文摘
2018/05/23
1.6K0
如何获得白色背景产品5--手动裁剪产品
手工剪裁的产品可以称为传统的获取白色背景的方式。您可以使用Photoshop及其各种工具(如磁性套索或钢笔)来勾勒产品的轮廓,将产品整体抠出来,然后更换想要的背景,例如纯白色。
ORBITVU_欧保图
2023/04/17
6640
如何获得白色背景产品5--手动裁剪产品
BI 产品中过滤器设置
腾讯云商业智能分析团队
2017/09/15
3.2K0
BI 产品中过滤器设置
基础篇-ObjectC继承、类别、属性
    在实际的开发过程中,继承和类别都会得到很多用处。对于界面相似度很高的情况下,使用继承可以节省很多代码和设置,只需要在子类中重写父类中的方法,或者增加新的子类方法即可,代码非常的简洁维护起来也很方便。下面小节下相关的知识,供需要的朋友查看。    在Objective-C中,给一个类扩展一个其它方法,有两种实现方式:类别和继承。
進无尽
2018/09/12
2K0
如何获得当前数据库的SCN值
Last Updated: Thursday, 2004-12-02 15:04 Eygle
数据和云01
2018/09/10
1.8K0
为什么以及如何从web.xml中获得参数?
马克-to-win:本 节要介绍几种从web.xml中获取参数的方法。有同学问,从web.xml当中获取参数有什么必要呢?直接把参数写到web.xml当中不就完了。实际 上在很多情况下,程序员编程序的
马克java社区
2021/07/07
1K0
如何从结果集中获得随机结果
全表扫描(Full table Scan) 全表扫描返回表中所有的记录。 执行全表扫描,Oracle读表中的所有记录,考查每一行是否满足WHERE条件。Oracle顺序的读分配给该表的每一个数据块,这样全表扫描能够受益于多块读. 每个数据块Oracle只读一次.
数据和云01
2018/09/10
1.6K0
Python 爬虫使用 Selenium 如何在 WebElement 获得属性
我们需要在 Doc 中选择我们的元素,这个叫做选择器,通常来说 HTML 很多不同的选择器。
HoneyMoose
2023/09/19
2020
Python 爬虫使用 Selenium 如何在 WebElement 获得属性
用init-param如何从web.xml中获得参数?
import javax.servlet.http.HttpServletRequest;
马克java社区
2021/07/07
1K0
Milvus 向量数据库如何实现属性过滤
如下图所示,Milvus 运用 EBNF 语法,此处用等式和语法图体现了 Milvus 所支持的查询表达式的整体规则。
Zilliz RDS
2022/05/25
1.7K0
Milvus 向量数据库如何实现属性过滤
如何追踪 WPF 程序中当前获得键盘焦点的元素并显示出来
我们有很多的调试工具可以帮助我们查看 WPF 窗口中当前获得键盘焦点的元素。本文介绍监控当前键盘焦点元素的方法,并且提供一个不需要任何调试工具的自己绘制键盘焦点元素的方法。
walterlv
2023/10/22
6180
如何追踪 WPF 程序中当前获得键盘焦点的元素并显示出来
如何从复盘中获得真正的收获?持续改进是关键!
复盘,本是围棋术语,每次博弈结束后,双方棋手把刚才的对局复演一遍,分析对局当中得失关键,提升自己棋力的好方法。复盘是对思维的训练。 通过复盘,当类似局面再次出现,你就能快速预测接下来的动态走向,更好应对。
JavaEdge
2023/06/10
4690
如何从复盘中获得真正的收获?持续改进是关键!
印度裔Kaggle大神自述:我是如何获得所有4个类别的Grandmaster
最近,一个印度裔Kaggle大神在论坛上分享了他获得4个类别的Grandmaster的经历。
量子位
2020/11/11
6580
印度裔Kaggle大神自述:我是如何获得所有4个类别的Grandmaster
UBUNTU中如何获得root权限
UBUNTU中如何获得root权限 在终端中输入: sudo passwd root Enter new UNIX password: (在这输入你的密码) Retype new UNIX password: (确定你输入的密码) passwd: password updated successfully 按照以上操作,即可完成新密码的设置。 以后,如果在想获得root权限,只需进行如下的操作: su root Password: (在此输入你上面设置的密码) 如果要再次禁用 root 帐号,那么可以执行
用户1685462
2021/07/28
3.5K0
点击加载更多

相似问题

WooCommerce -按产品属性和类别过滤相关产品

18

获取当前产品的可过滤属性

11

Magento -获得当前类别的所有产品

26

Flipkart产品API -如何从类别中获得最畅销的产品

10

如何在Woocommerce的产品页面中获得当前的类别ID?

51
添加站长 进交流群

领取专属 10元无门槛券

AI混元助手 在线答疑

扫码加入开发者社群
关注 腾讯云开发者公众号

洞察 腾讯核心技术

剖析业界实践案例

扫码关注腾讯云开发者公众号
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档