Skip to content

依托答辩,我就想用accessToken,https调一个API,看了半天阿里云文档看不出个所以然,阿里云泰酷辣 #19

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Ccheng2729111 opened this issue Aug 7, 2023 · 14 comments

Comments

@Ccheng2729111
Copy link

笑死

@tolerious
Copy link

同感

@yqz0203
Copy link

yqz0203 commented Aug 22, 2023

试了半天,终于跑起来了,文档确实一坨屎。 @Ccheng2729111

import dingtalk from '@alicloud/dingtalk';

 // @ts-ignore
  let client = new dingtalk.oauth2_1_0.default({
    protocol: 'https',
    regionId: 'central',
  });

  const getAccessTokenRequest = new dingtalk.oauth2_1_0.GetAccessTokenRequest({
    appKey: 'xxx',
    appSecret:
      'xxxx',
  });

  try {
    const res = await client.getAccessToken(getAccessTokenRequest);

    console.log(res.body.accessToken,res.body.expireIn);
  } catch (err) {
    console.log(err);
  }

@tolerious
Copy link

tolerious commented Aug 22, 2023

const { default: Dysmsapi20170525 } = require("@alicloud/dysmsapi20170525");
const { Config } = require("@alicloud/openapi-client");
const { default: Credential } = require("@alicloud/credentials");

const config = new Config({
    credential: new Credential(),
    regionId: "cn-shanghai",
    protocol: "http",
    accessKeyId: process.env.ACCESS_KEY_ID,
    accessKeySecret: process.env.ACCESS_KEY_SECRET,
  });
  const dysmsapiClient = new Dysmsapi20170525(config);
  let idiot = await dysmsapiClient.sendSms({
    phoneNumbers: 111111111,
    signName: "xxx",
    templateCode: "SMS_111111",
    templateParam: `{"code":"${c.code}"}`,
  });

经过测试,能跑。
把头部三个包装下。
@yqz0203 @Ccheng2729111 @JacksonTian @denverdino

@jpgaus
Copy link

jpgaus commented Sep 7, 2023

笑死

同感,阿里真是没落了,很简单东西,搞得巨复杂,文档写得一坨ss

@kejianfeng
Copy link

同感,一个那么简单的东西写的比专利还难懂,牛逼

@tolerious
Copy link

同感,一个那么简单的东西写的比专利还难懂,牛逼

可能我们的水平都太低了。 😄

@wenerme
Copy link

wenerme commented Nov 12, 2023

阿里云的文档和客户端都非常差,不介意可以试试最近封装的一个 client,基础功能有了,接口定义还在开发生成工具

https://github.com/wenerme/wode/tree/main/packages/client#alicloud

@ezxby
Copy link

ezxby commented Mar 23, 2024

能把一个短信包封装这么好,文档写的如此专业化,我相信阿里会引领世界100年不动摇

@ezxby
Copy link

ezxby commented Mar 23, 2024

阿里的确走下坡路了,就如同现在的淘宝,上比不了JD下比不了拼多多

@coloz
Copy link

coloz commented May 24, 2024

哈哈哈,完全同意,发个短信这么麻烦,这太阿里了

@tolerious
Copy link

tolerious commented May 27, 2024

哈哈哈,完全同意,发个短信这么麻烦,这太阿里了

What can we do? Uh? 😄

@TsinghuaDream
Copy link

感谢反馈。

关于SDK快速接入,我们制作了自动生成示例代码文档,完整工程中包含README文件,内含代码启动指令。https://help.aliyun.com/zh/sdk/developer-reference/how-to-automatically-generate-an-sdk-example

上述JS的问题,因为我们之前生成的都是TypeScript代码示例,可能理解上比较复杂,现在门户已经支持自动生成NodeJs代码示例了。

@uniquejava
Copy link

@TsinghuaDream 生成的好垃圾, 还好我只用jd购物 发验证码就几行代码的事情, 搞得不造火箭还复杂.

import SMSClient from '@alicloud/sms-sdk'

const smsClient = new SMSClient({
  accessKeyId:  'your key id',
  secretAccessKey: 'your secret',
})

const response = await smsClient.sendSMS({
...
}

简单明了, 你看看文档里都是什么乐色.

@uniquejava
Copy link

欣赏一下文档里(也是90%博客里出现的. 一群乌合之众..)

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants