public static com.aliyun.fc20230330.Client createClient() {// 工程代码建议使用更安全的无 AK// 方式,凭据配置方式请参见:https://help.aliyun.com/document_detail/378657.html。com.aliyun.credentials.models.Config credentialConfig = new com.aliyun.credentials.models.Config();credentialConfig.setType("access_key");// 必填参数,此处以从环境变量中获取AccessKey ID为例 credentialConfig.setAccessKeyId(BizConstants.ALIYUN_ACCESS_KEY_ID);// 必填参数,此处以从环境变量中获取AccessKey Secret为例 credentialConfig.setAccessKeySecret(BizConstants.ALIYUN_ACCESS_KEY_SECRET);com.aliyun.credentials.Client credentialClient = new com.aliyun.credentials.Client(credentialConfig);com.aliyun.teaopenapi.models.Config config = new com.aliyun.teaopenapi.models.Config();config.setCredential(credentialClient);String endpoint = String.format("%s.cn-shanghai.fc.aliyuncs.com", ACCOUNT_ID);config.setEndpoint(endpoint);try {return new com.aliyun.fc20230330.Client(config);} catch (Exception e) {logger.error(e.toString());return null;}}private String sendReqSync(String payload) {com.aliyun.fc20230330.Client client = createClient();ByteArrayInputStream bodyStream = new ByteArrayInputStream(payload.getBytes());com.aliyun.fc20230330.models.InvokeFunctionHeaders invokeFunctionHeaders = new com.aliyun.fc20230330.models.InvokeFunctionHeaders().setXFcInvocationType("Sync").setXFcLogType("Tail");com.aliyun.fc20230330.models.InvokeFunctionRequest invokeFunctionRequest = new com.aliyun.fc20230330.models.InvokeFunctionRequest().setQualifier("LATEST").setBody(bodyStream);com.aliyun.teautil.models.RuntimeOptions runtime = new com.aliyun.teautil.models.RuntimeOptions();try {com.aliyun.fc20230330.models.InvokeFunctionResponse resp = client.invokeFunctionWithOptions("createPPT20260514", invokeFunctionRequest, invokeFunctionHeaders, runtime);return new com.google.gson.Gson().toJson(resp);}catch (Exception _error) {TeaException error = new TeaException(_error.getMessage(), _error);logger.error(error.toString());}return null;}
阿里云这文档也写的太累了。绕来绕去的。看了半天。这里有演示代码系统。可以去看看。https://api.aliyun.com/document/FC/2023-03-30/InvokeFunction

