Web
为游戏集成需要支持社交功能的第三方渠道后,根据 Share 的说明实现分享功能。
实现分享功能
根据各个渠道的说明实现分享功能。
Facebook
使用以下数据结构调用 share 函数,third_type 为 facebook。
accountApi.share({
  third_type: 'facebook',
  href: '',
  hashtag: '#facebook share demo',
  app_id: 'xxxxx',
  display: 'popup',
})
| 参数 | 类型 | 说明 | 备注 | 
|---|---|---|---|
| third_type | string | 第三方渠道 类型 facebook | 必填 | 
| app_id | string | 申请 Facebook 应用的唯⼀标识符 | 必填 | 
| href | string | 对此帖⼦附加的链接 | 必填 | 
| display | string | 对话框呈现方式: page iframe popup touch 更多信息,请参见 分享对话框。  | 选填 | 
| redirect_uri | string | 用户点击对话框中的按钮后重新定向到此网址 | 选填 | 
Kakao
使用以下数据结构调用 share 函数,third_type 为 kakao。
accountApi.share({
  third_type: 'kakao',
  shareType: '',
  jsKey: '',
  href: '',
  text: '',
  imageUrl: '',
  title: '',
  description: ''
})
| 参数 | 类型 | 说明 | 备注 | 
|---|---|---|---|
| third_type | string | 第三方渠道 类型 kakao | 必填 | 
| shareType | string | 分享类型 story:kakao 故事 talk:kakao talk  | 必填 | 
| jsKey | string | kakao jskey | 必填 | 
| href | string | 分享页面 URL 当 shareType 是 story 时,分享页面可以设置背景图片和标题等 | |
| text | string | 自动输⼊的文字 不需要默认文字时可以设置成空字符串''  | 当 shareType 是 story 时必填 | 
| imageUrl | string | 分享页面背景图片 URL | 当 shareType 是 talk 时必填 | 
| title | string | 分享页面标题 | 当 shareType 是 talk 时必填 | 
| description | string | 分享页面描述 | 当 shareType 是 talk' 时需关注,选填 | 
Twitter
使用以下数据结构调用 share 函数,third_type 为 twitter。
accountApi.share({
  third_type: 'twitter',
  url: '',
  text: '',
  hashtag: '#twitter share demo',
})
| 参数 | 类型 | 说明 | 备注 | 
|---|---|---|---|
| third_type | string | 第三方渠道 类型 twitter | 必填 | 
| url | string | 共享 URL,将在已发布的推文中自动缩短 共享 URL 可能会出现⼀张卡片  | 选填 | 
| via | string | 使用 通过 参数标记用户 (@username) | 选填 | 
| text | string | 文本参数显示在推文编辑器中预选。 推文作者可以通过单个删除操作轻松删除文本  | 选填 | 
| hashtags | string | 使用 hashtags 参数向推文添加逗号分隔的主题标签列表 | 选填 | 
VK
使用以下数据结构调用 share 函数,third_type 为 vk。
accountApi.share({
  third_type: 'vk',
  url: '',
  image: '',
  title: 'vk share demo',
})
| 参数 | 类型 | 说明 | 备注 | 
|---|---|---|---|
| third_type | string | 第三方渠道 类型 vk | 必填 | 
| url | string | 分享链接 | 必填 | 
| image | string | 图片地址 | 选填 | 
| title | string | 标题 | 选填 |