获取直播列表出错?
发布于 6 年前 作者 oliu 5567 次浏览 来自 问答

我的云函数代码

const cloud = require('wx-server-sdk')

const rp = require('request-promise')

cloud.init() 

exports.main = async (event, context) => { 

 const options = {

 method: 'POST',

 url: 'https://api.weixin.qq.com/wxa/business/getliveinfo' ,

 qs: {

  access_token:event.token,

start:0,

limit:50,

 },

 json: true

 };

 //获取AccessToken

return await rp(options);

}

调用该云函数返回{errcode: 41001, errmsg: “access_token missing rid: 5fa3d9a2-477a4656-7f17fd9e”}

2 回复

access_token通过如下云函数获得

const cloud = require('wx-server-sdk')

const rp = require('request-promise')

cloud.init() 

// 云函数入口函数

exports.main = async (event, context) => { 

 //appid和秘钥

 const appid = 'wx426d5530727bdaed',

 secret = 'xxx';

 const AccessToken_options = {

 method: 'GET',

 url: 'https://api.weixin.qq.com/cgi-bin/token',

 qs: {

 appid,

 secret,

 grant_type: 'client_credential'

 },

 json: true

 };

 //获取AccessToken

return await rp(AccessToken_options);

}

确认下是否真的带上了access_token

回到顶部