日韩无码专区无码一级三级片|91人人爱网站中日韩无码电影|厨房大战丰满熟妇|AV高清无码在线免费观看|另类AV日韩少妇熟女|中文日本大黄一级黄色片|色情在线视频免费|亚洲成人特黄a片|黄片wwwav色图欧美|欧亚乱色一区二区三区

RELATEED CONSULTING
相關(guān)咨詢(xún)
選擇下列產(chǎn)品馬上在線溝通
服務(wù)時(shí)間:8:30-17:00
你可能遇到了下面的問(wèn)題
關(guān)閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營(yíng)銷(xiāo)解決方案
微信公眾號(hào)發(fā)放激活碼

什么是Serverless?

Serverless是一種云計(jì)算服務(wù)模式,它將計(jì)算資源的管理與服務(wù)的開(kāi)發(fā)分離,在這種模式下,開(kāi)發(fā)者無(wú)需關(guān)心底層的服務(wù)器維護(hù),只需關(guān)注業(yè)務(wù)邏輯的實(shí)現(xiàn),Serverless架構(gòu)可以極大地降低開(kāi)發(fā)和運(yùn)維成本,提高開(kāi)發(fā)效率,目前,Serverless主要有兩種形式:無(wú)服務(wù)器計(jì)算(Serverless Function)和無(wú)服務(wù)器事件驅(qū)動(dòng)(Serverless Event Driven),本文將以Serverless Function為例,介紹如何基于微信公眾號(hào)簡(jiǎn)單管理用戶(hù)激活碼。

創(chuàng)新互聯(lián)建站是專(zhuān)業(yè)的縉云網(wǎng)站建設(shè)公司,縉云接單;提供網(wǎng)站制作、網(wǎng)站建設(shè),網(wǎng)頁(yè)設(shè)計(jì),網(wǎng)站設(shè)計(jì),建網(wǎng)站,PHP網(wǎng)站建設(shè)等專(zhuān)業(yè)做網(wǎng)站服務(wù);采用PHP框架,可快速的進(jìn)行縉云網(wǎng)站開(kāi)發(fā)網(wǎng)頁(yè)制作和功能擴(kuò)展;專(zhuān)業(yè)做搜索引擎喜愛(ài)的網(wǎng)站,專(zhuān)業(yè)的做網(wǎng)站團(tuán)隊(duì),希望更多企業(yè)前來(lái)合作!

如何獲取微信公眾號(hào)的access_token?

在進(jìn)行后續(xù)操作之前,我們需要先獲取微信公眾號(hào)的access_token,access_token是微信公眾號(hào)接口調(diào)用的憑證,有了它,我們才能調(diào)用微信公眾號(hào)提供的各種接口,獲取access_token的方法如下:

1、登錄微信公眾平臺(tái)官網(wǎng):https://mp.weixin.qq.com/

2、在左側(cè)菜單欄中選擇“開(kāi)發(fā)者中心”。

3、在開(kāi)發(fā)者中心頁(yè)面中,點(diǎn)擊“基本配置”。

4、將網(wǎng)站配置為公眾號(hào)后,點(diǎn)擊“修改配置”。

5、在彈出的窗口中,填寫(xiě)網(wǎng)站URL、Token等信息,然后點(diǎn)擊“提交”。

6、審核通過(guò)后,即可在“開(kāi)發(fā)者中心”頁(yè)面看到access_token。

如何使用Serverless Function生成用戶(hù)激活碼?

在獲取到access_token后,我們可以使用Serverless Function來(lái)生成用戶(hù)激活碼,以下是一個(gè)簡(jiǎn)單的示例:

1、安裝Node.js環(huán)境,Node.js是運(yùn)行Serverless Function的運(yùn)行時(shí)環(huán)境。

2、創(chuàng)建一個(gè)新的文件夾,用于存放我們的Serverless Function代碼,在該文件夾中,創(chuàng)建一個(gè)名為index.js的文件,并編寫(xiě)以下代碼:

const cloud = require('wx-server-sdk')
cloud.init()
const db = cloud.database()
const _ = db.command
exports.main = async (event, context) => {
  const wxContext = cloud.getWXContext()
  const { OPENID } = wxContext
  const activationCode = Math.random().toString(36).substr(2, 9) // 生成一個(gè)9位數(shù)的隨機(jī)激活碼
  try {
    await db.collection('activationCodes').add({
      _openid: OPENID,
      code: activationCode,
      createTime: new Date().getTime(),
    })
  } catch (e) {
    console.error('Error creating activation code:', e)
    return 'Error creating activation code'
  }
  return activationCode
}

3、在package.json文件中,添加以下內(nèi)容:

{
  "name": "activation-code",
  "version": "1.0.0",
  "description": "Generate user activation codes",
  "scripts": {
    "start": "node index.js"
  },
  "dependencies": {},
  "devDependencies": {},
  "keywords": [],
  "author": "",
  "license": "ISC",
  "bugs": {
    "url": ""
  },
  "homepage": "",
  "repository": {},
  "npmVersion": "6.0.0",
  "engines": {
    'node': '>=8.0.0',
    'npm': '>=5',
    'yarn': '^1.21.1'
  }
}

4、在命令行中,進(jìn)入到index.js所在的文件夾,運(yùn)行以下命令啟動(dòng)Serverless Function:

npm start --only serverless --region  --debug true --verbose true --stack-trace true --function-name activation-code --memory-size  --timeout  --stage  --env  --region  --debug true --verbose true --stack-trace true --function-name activation-code --memory-size  --timeout  --stage  --env  --region  --debug true --verbose true --stack-trace true --function-name activation-code --memory-size  --timeout  --stage  --env  --region  --debug true --verbose true --stack-trace true --function-name activation-code --memory-size  --timeout  --stage  --env  --region  --debug true --verbose true --stack-trace true --function-name activation-code --memory-size  --timeout  --stage  --env  --region  --debug true --verbose true --stack-trace true --function-name activation-code --memory-size  --timeout  --stage  --env  --region  --debug true --verbose true --stack-trace true --function-name activation-code --memory-size  --timeout  --stage  --env  --region  --debug true --verbose true --stack-trace true --function-name activation-code --memory-size 
                                                                                                        
網(wǎng)頁(yè)標(biāo)題:微信公眾號(hào)發(fā)放激活碼
轉(zhuǎn)載注明:http://www.5511xx.com/article/coophoj.html