60 lines
2.3 KiB
PHP
60 lines
2.3 KiB
PHP
|
<?php
|
|||
|
require_once __DIR__.'/../../../vendor/autoload.php';
|
|||
|
use TencentCloud\Ess\V20201111\EssClient;
|
|||
|
use TencentCloud\Ess\V20201111\Models\UserInfo;
|
|||
|
use TencentCloud\Ess\V20201111\Models\FormField;
|
|||
|
use TencentCloud\Ess\V20201111\Models\CreateDocumentRequest;
|
|||
|
use TencentCloud\Common\Exception\TencentCloudSDKException;
|
|||
|
use TencentCloud\Common\Credential;
|
|||
|
use TencentCloud\Common\Profile\ClientProfile;
|
|||
|
use TencentCloud\Common\Profile\HttpProfile;
|
|||
|
|
|||
|
try {
|
|||
|
// 实例化一个证书对象,入参需要传入腾讯云账户secretId,secretKey
|
|||
|
$cred = new Credential("********************************", "********************************");
|
|||
|
|
|||
|
// 实例化一个http选项,可选的,没有特殊需求可以跳过
|
|||
|
$httpProfile = new HttpProfile();
|
|||
|
$httpProfile->setReqMethod("POST"); // post请求(默认为post请求)
|
|||
|
$httpProfile->setReqTimeout(30); // 请求超时时间,单位为秒(默认60秒)
|
|||
|
$httpProfile->setEndpoint("ess.tencentcloudapi.com"); // 指定接入地域域名(默认就近接入)
|
|||
|
|
|||
|
// 实例化一个client选项,可选的,没有特殊需求可以跳过
|
|||
|
$clientProfile = new ClientProfile();
|
|||
|
$clientProfile->setSignMethod("TC3-HMAC-SHA256"); // 指定签名算法(默认为HmacSHA256)
|
|||
|
$clientProfile->setHttpProfile($httpProfile);
|
|||
|
|
|||
|
$client = new EssClient($cred, "ap-guangzhou", $clientProfile);
|
|||
|
|
|||
|
$req = new CreateDocumentRequest();
|
|||
|
|
|||
|
$userInfo = new UserInfo();
|
|||
|
$userInfo->setUserId("********************************");
|
|||
|
$req->setOperator($userInfo);
|
|||
|
|
|||
|
$req->FileNames = [];
|
|||
|
// 无需关注,传入自定义任意值即可
|
|||
|
array_push($req->FileNames, "filename");
|
|||
|
|
|||
|
// 由CreateFlow返回
|
|||
|
$req->setFlowId("********************************");
|
|||
|
|
|||
|
// 后台配置后查询获取
|
|||
|
$req->setTemplateId("********************************");
|
|||
|
|
|||
|
$formField = new FormField();
|
|||
|
// 在模板配置拖入控件的界面可以查询到
|
|||
|
$formField->setComponentName("********************************");
|
|||
|
$formField->setComponentValue("********************************");
|
|||
|
|
|||
|
$req->FormFields = [];
|
|||
|
array_push($req->FormFields, $formField);
|
|||
|
|
|||
|
$resp = $client->CreateDocument($req);
|
|||
|
|
|||
|
// 输出json格式的字符串回包
|
|||
|
print_r($resp->toJsonString());
|
|||
|
}
|
|||
|
catch(TencentCloudSDKException $e) {
|
|||
|
echo $e;
|
|||
|
}
|