CreateFlowByFile.php 3.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. <?php
  2. require_once __DIR__.'/../../../vendor/autoload.php';
  3. use TencentCloud\Ess\V20201111\EssClient;
  4. use TencentCloud\Ess\V20201111\Models\CreateFlowByFilesRequest;
  5. use TencentCloud\Ess\V20201111\Models\UserInfo;
  6. use TencentCloud\Ess\V20201111\Models\ApproverInfo;
  7. use TencentCloud\Ess\V20201111\Models\Component;
  8. use TencentCloud\Common\Exception\TencentCloudSDKException;
  9. use TencentCloud\Common\Credential;
  10. use TencentCloud\Common\Profile\ClientProfile;
  11. use TencentCloud\Common\Profile\HttpProfile;
  12. try {
  13. // 实例化一个证书对象,入参需要传入腾讯云账户secretId,secretKey
  14. $cred = new Credential("********************************", "********************************");
  15. // 实例化一个http选项,可选的,没有特殊需求可以跳过
  16. $httpProfile = new HttpProfile();
  17. $httpProfile->setReqMethod("POST"); // post请求(默认为post请求)
  18. $httpProfile->setReqTimeout(30); // 请求超时时间,单位为秒(默认60秒)
  19. $httpProfile->setEndpoint("ess.tencentcloudapi.com"); // 指定接入地域域名(默认就近接入)
  20. // 实例化一个client选项,可选的,没有特殊需求可以跳过
  21. $clientProfile = new ClientProfile();
  22. $clientProfile->setSignMethod("TC3-HMAC-SHA256"); // 指定签名算法(默认为HmacSHA256)
  23. $clientProfile->setHttpProfile($httpProfile);
  24. $client = new EssClient($cred, "ap-guangzhou", $clientProfile);
  25. $req = new CreateFlowByFilesRequest();
  26. $userInfo = new UserInfo();
  27. $userInfo->setUserId("********************************");
  28. $req->setOperator($userInfo);
  29. $req->FileIds = [];
  30. array_push($req->FileIds, "********************************");
  31. // 企业方 静默签署时type为3/非静默签署type为0
  32. $approver1 = new ApproverInfo();
  33. $approver1->setApproverType(3);
  34. $approver1->setApproverName("********************************");
  35. $approver1->setApproverMobile("********************************");
  36. $approver1->setOrganizationName("********************************");
  37. $component1 = new Component();
  38. $component1->setComponentValue("********************************");
  39. $component1->setComponentPosY(497.61545);
  40. $component1->setComponentWidth(74);
  41. $component1->setFileIndex(0);
  42. $component1->setComponentType("SIGN_SEAL");
  43. $component1->setComponentPage(1);
  44. $component1->setComponentPosX(417.15625);
  45. $component1->setComponentHeight(70);
  46. $approver1->SignComponents = [];
  47. array_push($approver1->SignComponents, $component1);
  48. // 客户个人
  49. $approver2 = new ApproverInfo();
  50. $approver2->setApproverType(1);
  51. $approver2->setApproverName("********************************");
  52. $approver2->setApproverMobile("********************************");
  53. $component2 = new Component();
  54. $component2->setComponentPosY(472.78125);
  55. $component2->setComponentWidth(112);
  56. $component2->setFileIndex(0);
  57. $component2->setComponentType("SIGN_SIGNATURE");
  58. $component2->setComponentPage(1);
  59. $component2->setComponentPosX(146.15625);
  60. $component2->setComponentHeight(40);
  61. $approver2->SignComponents = [];
  62. array_push($approver2->SignComponents, $component2);
  63. // 注:当进行B2B签署时,允许指向未注册的企业,此时签署人可以查看合同并按照指引注册企业
  64. $req->Approvers = [];
  65. array_push($req->Approvers, $approver1);
  66. array_push($req->Approvers, $approver2);
  67. $req->setFlowName("********************************");
  68. // 请设置合理的时间,否则容易造成合同过期
  69. $req->setDeadLine(time() + 7 * 24 * 3600);
  70. $resp = $client->CreateFlowByFiles($req);
  71. // 输出json格式的字符串回包
  72. print_r($resp->toJsonString());
  73. }
  74. catch(TencentCloudSDKException $e) {
  75. echo $e;
  76. }