tt.shareMessageToFriend
基础库 2.74.0 开始支持本方法,这是一个异步方法。
给指定的好友分享游戏信息。
前提条件 | 无 |
业务背景 | 无 |
使用限制 | 目前仅支持 抖音、抖音极速版 APP |
注意事项 |
|
相关教程 | 无 |
语法
tt.shareMessageToFriend(options)
参数说明
options 为 object 类型,属性如下:
属性名 | 类型 | 默认值 | 必填 | 说明 | 最低支持版本 |
---|---|---|---|---|---|
query | string | 否 | 查询字符串,格式为JSONString。从这条转发消息进入后,可通过 tt.getLaunchOptionsSync 或 tt.onShow 获取启动参数中的 query 用来实现信息透传 | 2.74.0 | |
openId | string | 是 | 发送对象的 openId | 2.74.0 | |
templateId | string | 是 | 分享素材模板 id,指定通过平台审核的 templateId 来选择分享内容,需在平台设置且通过审核 | 2.74.0 | |
success | function | 否 | 接口调用成功的回调函数 | 2.74.0 | |
fail | function | 否 | 接口调用失败的回调函数 | 2.74.0 | |
complete | function | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) | 2.74.0 |
回调成功
object 类型,属性如下:
属性名 | 类型 | 说明 | 最低支持版本 |
---|---|---|---|
errMsg | string | "shareMessageToFriend:ok" | 2.74.0 |
回调失败
object 类型,属性如下:
属性名 | 类型 | 说明 | 最低支持版本 |
---|---|---|---|
errMsg | string | "shareMessageToFriend:fail" + 详细错误信息 | 2.74.0 |
错误码
errNo | errMsg | 说明 | 最低支持版本 |
---|---|---|---|
0 | get game user info error | 2.74.0 | |
0 | get share info error | 2.74.0 | |
10502 | cancel | 2.74.0 | |
20001 | invalid param | 参数错误 | 2.74.0 |
20000 | frequency_control | 今天TA接受到的邀请太多啦,明天再试试吧 | 2.74.0 |
21500 | get game user info catch error | 小游戏框架内部错误,有需要请创建工单咨询 | 2.74.0 |
21500 | get share info catch error${JSON.stringify(error)} | 小游戏框架内部错误,有需要请创建工单咨询 | 2.74.0 |
10301 | feature is not supported in app | 2.74.0 | |
21101 | sendMessage is in progress, please do not call again | 2.74.0 | |
21000 | container not exist | 小游戏框架内部错误,有需要请创建工单咨询 | 2.74.0 |
21000 | no openID | 2.74.0 | |
21000 | query error | 2.74.0 | |
21000 | schema error | 2.74.0 | |
21000 | query conent error | 2.74.0 | |
21000 | sec_uid not exist | 2.74.0 | |
21000 | get target uid failed | 小游戏框架内部错误,有需要请创建工单咨询 | 2.74.0 |
21000 | sendMessage failed | 小游戏框架内部错误,有需要请创建工单咨询 | 2.74.0 |
20000 | internal error | 小游戏框架内部错误,有需要请创建工单咨询 | 2.74.0 |
10601 | shareMessageToFriend | 2.74.0 | |
21000 | sendGameInviteMessage failed | 小游戏框架内部错误,有需要请创建工单咨询 | 2.74.0 |
21000 | sendGameInviteMessage failed | 小游戏框架内部错误,有需要请创建工单咨询 | 2.74.0 |
21000 | sendGameInviteMessage failed | 小游戏框架内部错误,有需要请创建工单咨询 | 2.74.0 |
21000 | sendGameInviteMessage failed | 小游戏框架内部错误,有需要请创建工单咨询 | 2.74.0 |
21000 | sendGameInviteMessage failed | 小游戏框架内部错误,有需要请创建工单咨询 | 2.74.0 |
10402 | native exception | 小游戏框架内部错误,有需要请创建工单咨询 | 2.74.0 |
20000 | share info entity error | 2.74.0 | |
20000 | game user info entity error | 2.74.0 |
代码示例
let queryObj = { 'key1': 'value1', 'key2': 'value2', }; tt.shareMessageToFriend({ openId: 'xxxxx', templateId: 'xxxxxx', query: JSON.stringify(queryObj), success(res) { console.log('success'); }, fail(res) { console.log('fail', res); }, });