阿里个人短信验证码从申请到代码实现全流程

首先:进入阿里云-云市场官网,然后进行就是登陆操作:这个就不用说了,有阿里云账号就用阿里云账号,用支付宝或淘宝账号也可以,都没有就注册一个就行了。

说明:目前个人开发者比较容易申请到的只有验证码的短信服务,其他的类型短信服务需要公司的营业执照等信息

详细教程开始

1、开通阿里云短信服务(按步骤点击即可)

     点击短信服务后,好像会弹出一个开通该服务的窗口,点一下同意就可以开通了

 

2、充值

     1)开通阿里云的短信服务是不要钱的,但是发送短信是要钱的,

      2)目前收费标准:1-10万单价是0.045元/条,10-30万单价是0.04元/条,若您当月累计用了15万,则消费金额为15万*0.04元/条。

      3)在个人控制台中,进行充值操作。在1中查看自己账号中是否有余额,没有的话点击2(费用)-->充值,进行充值操作(不进行赘述了)

  • 2
    点赞
  • 27
    收藏
    觉得还不错? 一键收藏
  • 6
    评论
以下是一个简单的示例,使用Vue实现阿里短信验证码登录的代码: ``` <template> <div> <input type="tel" v-model="phone" placeholder="请输入手机号码"> <button @click="sendCode" :disabled="isSending">{{ buttonText }}</button> <input type="text" v-model="code" placeholder="请输入验证码"> <button @click="login" :disabled="!code || isLoggingIn">登录</button> </div> </template> <script> import { sendVerificationCode, loginWithVerificationCode } from '@/api/auth' export default { data() { return { phone: '', code: '', isSending: false, isLoggingIn: false, countdown: 60, buttonText: '获取验证码' } }, methods: { async sendCode() { if (!this.phone) { return this.$message.error('请输入手机号码') } this.isSending = true try { await sendVerificationCode(this.phone) this.countdown = 60 this.buttonText = `${this.countdown}秒后重新发送` const timer = setInterval(() => { this.countdown-- this.buttonText = `${this.countdown}秒后重新发送` if (this.countdown === 0) { clearInterval(timer) this.isSending = false this.buttonText = '获取验证码' } }, 1000) } catch (err) { this.isSending = false this.$message.error(err.message) } }, async login() { if (!this.code) { return this.$message.error('请输入验证码') } this.isLoggingIn = true try { await loginWithVerificationCode(this.phone, this.code) this.$message.success('登录成功') // 跳转到首页 } catch (err) { this.isLoggingIn = false this.$message.error(err.message) } } } } </script> ``` 在此示例中,我们使用了 `sendVerificationCode` 和 `loginWithVerificationCode` 两个方法来发送验证码和登录。您需要根据您自己的实际情况来实现这些方法,这些方法通常会与您的后端API进行交互。 此外,您需要在阿里云控制台中创建一个短信模板,并将其与您的应用程序集成。您需要使用阿里云提供的SDK来发送短信验证码

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值