CreatFlow.php 2.8 KB

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