当前位置: 首页 > news >正文

阿里云,函数计算3.0 发送请求演示代码

    public static com.aliyun.fc20230330.Client createClient() {// 工程代码建议使用更安全的无 AK// 方式,凭据配置方式请参见:https://help.aliyun.com/document_detail/378657.htmlcom.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

 

image

 

http://www.jsqmd.com/news/830272/

相关文章:

  • 利用 TaoToken 为多租户 SaaS 平台提供模型路由与隔离
  • 5大核心功能:秋之盒ADB工具箱让你3分钟告别命令行恐惧
  • 20260516 大势与大盘——通胀升温及顶背离下的高风险市场
  • Go语言实现M3U8视频下载器:技术原理与实战应用深度解析
  • ollma lm studio
  • ElevenLabs语音克隆失败率骤降63%的关键:训练集音频信噪比阈值、时长分布与语速归一化黄金公式
  • 2026年国内高性价比GEO优化服务商选型格局与核心能力分析报告 - 产业观察网
  • 系统安装:安装Ubuntu 26.04 LTS
  • 基于TPYBoard与接近开关的金属检测仪DIY实战
  • 告别Houdini依赖!UE5.2 PCG插件实战:5分钟搞定程序化场景搭建(附节点详解)
  • 在多模型聚合平台上进行模型选型与性能对比测试
  • 实战指南:在Linux系统免费安装Adobe Illustrator CC 17专业设计工具
  • 【ElevenLabs希伯来文语音实战指南】:20年AI语音工程师亲测的5大避坑要点与本地化交付标准
  • 2026年国内专业AI搜索生成式优化服务商选型分析与优质机构梳理 - 产业观察网
  • PHP 的多态机制的庖丁解牛
  • 在Taotoken模型广场中为不同任务选择合适模型的思路
  • 解锁Midjourney V6针孔相机效果:从模糊边缘到胶片噪点,7步零代码复刻1950年代Lomography美学
  • AI导致能力退化,怎么前行
  • 精细化设计引领升级,超窄带滤光片产品竞争力持续上扬
  • PowerQUICC III通信处理器架构解析与MPC8541E实战开发指南
  • Windows系统管家:WinUtil一键安装与优化完整指南
  • 2026年配音软件实测:7款工具独立评分,免费、效率、克隆哪款适合你? - AI测评
  • 原子化《清单革命》的庖丁解牛
  • 如何在macOS上优雅运行Windows程序:Whisky完整指南
  • 【独家首发】ElevenLabs法语语音API未公开高级参数手册(含voice_stability、similarity_boost、style_expansion隐藏阈值):仅限前500名订阅者获取
  • 用STM32CubeMX和HAL库,5分钟搞定Nooploop TOFSense激光测距模块的串口通信
  • 终极指南:五分钟免费将CAJ文件转换为可搜索PDF
  • 告别手动转换:用InterMol一键搞定LAMMPS到GROMACS的拓扑文件(附LiTFSI/PEO电解质实战)
  • 人生思维陷阱的庖丁解牛
  • 揭秘OpenRGB:终结RGB设备碎片化控制的革命性开源方案