CreateDocument.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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\FormField;
  6. use TencentCloud\Ess\V20201111\Models\CreateDocumentRequest;
  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 CreateDocumentRequest();
  25. $userInfo = new UserInfo();
  26. $userInfo->setUserId("********************************");
  27. $req->setOperator($userInfo);
  28. $req->FileNames = [];
  29. // 无需关注,传入自定义任意值即可
  30. array_push($req->FileNames, "filename");
  31. // 由CreateFlow返回
  32. $req->setFlowId("********************************");
  33. // 后台配置后查询获取
  34. $req->setTemplateId("********************************");
  35. $formField = new FormField();
  36. // 在模板配置拖入控件的界面可以查询到
  37. $formField->setComponentName("********************************");
  38. $formField->setComponentValue("********************************");
  39. $req->FormFields = [];
  40. array_push($req->FormFields, $formField);
  41. $resp = $client->CreateDocument($req);
  42. // 输出json格式的字符串回包
  43. print_r($resp->toJsonString());
  44. }
  45. catch(TencentCloudSDKException $e) {
  46. echo $e;
  47. }