# 开通

  • 登录新浪微博开放平台,打开 “移动应用 MOBILE” 页面
  • 在页面中选择 “立即接入”,根据提示填写信息创建应用
  • 创建成功后,在 “我的应用” 中点击应用,可以在应用详情页面
  • 在应用详情页面的 “应用信息” -> “基本信息” 中可获取 App Key,点击编辑可设置iOS平台的通用链接(UniversalLink)

For more information, please refer to the official Sina Weibo document Mobile Application Access

# 配置

  • appkey 新浪微博开放平台申请应用的AppKey值
  • redirect_url 新浪微博开放平台申请应用中设置的回调页
  • UniversalLinks iOS平台通用链接,必须与新浪微博开放平台配置的一致,推荐使用一键生成iOS通用链接

Notice

  • The standard real machine running base in HBuilderX uses the AppID and other information that DCloud applies for the HBuilder application, which is only used to experience the Sina Weibo sharing function
  • The configuration parameters need to be submitted to the cloud to be packaged to take effect. Please use the [custom debugging base] when the real machine is running (https://ask.dcloud.net.cn/article/35115)

# 使用新浪微博分享

# 示例代码

  • uni-app项目
uni.share({
    provider: 'sinaweibo',
	success: function (res) {
		console.log("success:" + JSON.stringify(res));
	},
	fail: function (err) {
		console.log("fail:" + JSON.stringify(err));
	}
});
  • 5+ App项目
var weiboShare = null;
plus.share.getServices(function(services) {
	for (var i in services) {
		var service = services[i];
		// 获取微博分享对象
		if (service.id == 'sinaweibo') {
			weiboShare = service;
			break;
		}
	}
	weiboShare.send( {
	}, function(){
		// 分享成功
	}, function(err) {
    // 分享操作失败
    // err.code is the error code
	})
}, function(err) {
	// Failed to get services
})