小程序开放平台

文档中心
暂无目录

xhs.followOfficialAccount

更新时间:2024-11-13 19:05:30

xhs.followOfficialAccount

基础库版本 >= 3.28.0 开始支持本方法。

用于引导用户关注小红书店铺

语法

  xhs.followOfficialAccount(options)

参数说明

options 为 object 类型,属性如下:

属性名
类型
必填
说明
最低支持版本
successFunction接口调用成功的回调函数3.28.0
failFunction接口调用失败的回调函数3.28.0
completeFunction接口调用结束的回调函数(调用成功、失败都会执行)3.28.0

回调成功

属性
类型
说明
最低支持版本
errMsgstringfollowOfficialAccount:ok3.28.0
statusnumber调用状态码 status3.28.0

状态码(status)说明

status
number
说明
最低支持版本
0number关注成功3.28.0
1number已关注3.28.0
2number关注失败3.28.0
3number获取关注状态异常3.28.0

回调失败

属性
类型
说明
最低支持版本
errMsgstringfollowOfficialAccount:fail + 错误信息3.28.0

代码示例

  xhs.followOfficialAccount({
    success(res) {
      if (res.errCode === 0) {
        console.log("关注成功");
      } else {
        console.log(res.errMsg);
      }
    },
  });

Bug & Tip

  • tip:只能在 bindtap 中使用该 api
  • 小红书暂不提供用户关注状态的查询