shareSDKPlus

来自于:Mob官方立即使用

iOS配置 android配置 常量须知 authorize cancelAuthorize getUserInfo shareContent oneKeyShareContent

概述

当前ShareSDK版本,iOS:v4.3.3、android:v3.6.8

ShareSDK简介

ShareSDK是为iOS、Android的App提供社交分享功能的一个组件,开发者仅需10分钟即可集成到自己的App中,它不仅支持包括QQ、微信、新浪微博、腾讯微博、豆瓣、Facebook、Twitter、Google+等国内外40多家的主流社会平台,未来继续不断扩展。帮助开发者轻松实现社会分享、第三方登录、关注、获得用户资料、获取好友列表等主流的功能,还有强大的社会化统计分享分析管理后台,可以实时了解用户、分享量、回流率等数据,有效地指导移动App的日常运营与推广,同时为App引入更多的社会平台流量。

ShareSDK功能

  • 第三方登录,即用微信、QQ、微博等社交网络账号登录,用户不必经过填写注册信息、上传头像等繁琐步骤就可使用App。
  • 一键分享,支持分享图文、音乐、视频、链接等各种富媒体内容,在App界面点击分享至该社交平台,不用弹出分享菜单栏,实现一键分享。
  • 短链转换,在分享出去的链接中,用户看到的是您官方地址,而非ShareSDK;开启短链转换后,实时统计回流率,帮助开发者精细化运营。
  • 好友关系运用,轻松实现获取微博好友关系、微博内容、用户资料、LBS信息,建立好友链,活跃社区氛围,增加用户粘度。
  • 数据统计分析,ShareSDK后台实时统计分享数、分享回流率、用户分布、社交平台选择等数据,全面诊断App各维度,助力产品优化改进。
  • 评论和点赞,用户在登录后可对你设置的主题进行评论或点赞,同时您也能在后台审核评论内容,建立良好的社区氛围。

shareSDKPlus 模块概述

shareSDKPlus封装了ShareSDK,是对APICloud平台的支持,为APICloud开发的App提供社交分享功能的一个组件,支持包括QQ、微信、新浪微博等多家主流社会平台,帮助开发者轻松实现社会分享、第三方登录、关注、获得用户资料、获取好友列表等主流的功能。

如有问题请联系技术支持:

  1. 服务电话: 400-685-2216
  2. 节假日值班电话:
  3. iOS185-1664-1951
  4. Android: 185-1664-1950
  5. 电子邮箱: support@mob.com
  6. 市场合作: 021-54623189

模块使用攻略

开发者使用本模块之前需要先到Mob官网申请开发者账号,并在账号内填写相应信息创建自己的 APP,从而获取AppKey和AppSecret,然后添加ShareSDK功能。
详情参考:快速集成获取apppkey和appSecret

使用此模块之前建议先配置 config.xml 文件,配置完毕,需通过云端编译生效,配置方法如下:

iOS配置:

1.配置config.xml文件 下面是配置各个平台urlScheme列子,开发者自行删减。下面的值都是sharesdk demo测试使用,开发者自行调整

  1. <feature name="shareSDKPlus">
  2. <param name="urlScheme" value="wx617c77c82218ea2c" />
  3. <param name="urlScheme" value="wb568898243" />
  4. <param name="urlScheme" value="tencent100371282" />
  5. <param name="urlScheme" value="QQ05FB8B52" />
  6. <param name="urlScheme" value="ap2017062107540437" />
  7. <param name="urlScheme" value="fb1412473428822331" />
  8. <param name="urlScheme" value="line3rdp.com.mob.product.ShareSDK" />
  9. <param name="urlScheme" value="yx0d9a9f9088ea44d78680f3274da1765f" />
  10. <param name="urlScheme" value="pdk4987008320438021391" />
  11. <param name="urlScheme" value="kakao9c17eb03317e0e627ec95a400f5785fb" />
  12. <param name="urlScheme" value="dingoabcwtuab76wy0kyzo" />
  13. <param name="urlScheme" value="pocketapp1234" />
  14. <param name="urlScheme" value="vk5312801" />
  15. <param name="urlScheme" value="twitterkit-viOnkeLpHBKs6KXV7MPpeGyzE" />
  16. <param name="urlScheme" value="rm226427com.mob.product.ShareSDK" />
  17. <param name="urlScheme" value="ak1412473428822331" />
  18. <param name="urlScheme" value="aw9ivykfjvi4hpwo" />
  19. </feature>

字段描述:

urlScheme:用于实现应用间跳转及数据交换,跳转到第三方应用客户端进行分享或授权后,从第三方应用客户端平台跳回到当前应用。urlScheme的value值根据第三方平台规则设置。可以配置多个urlScheme。

各个平台配置规范:
微信:微信开放平台获取的appid,URL scheme为wx+appid 如:wx617c77c82218ea2c

QQ:填两个URL scheme: 一个是tencent + appId ; 一个是 QQ + appId 转换成的十六进制(如果appId转换的16进制数不够8位则在前面补0,如转换的是:5FB8B52,则最终填入为:QQ05FB8B52 注意:转换后的字母要大写),这里的 QQ 一定要是大写

新浪微博:新浪微博开放平台获取到的appkey,URL scheme为wb+appkey 如:wb568898243

Facebook:URL scheme为fb+appid 如:fb1412473428822331

2.配置 key.xml 文件
需要将第三方平台(微博、QQ、微信、twitter、facebook等)申请的appkey、appsecret、redirecturi等参数配置到 key.xml 文件中。
key.xml 配置详解:
key.xml 文件需要放在 widget://res 文件目录下,格式如下:

  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <security>
  3. <item name="shareSDKPlus_SinaWei_AppKey" value="568898243" />
  4. <item name="shareSDKPlus_SinaWei_AppSecret" value="38a4f8204cc784f81f9f0daaf31e02e3" />
  5. <item name="shareSDKPlus_SinaWei_RedirectUri" value="http://www.sharesdk.cn" />
  6. <item name="shareSDKPlus_QQ_AppKey" value="100371282" />
  7. <item name="shareSDKPlus_QQ_AppSecret" value="aed9b0303e3ed1e27bae87c33761161d" />
  8. <item name="shareSDKPlus_Wechat_AppKey" value="wx617c77c82218ea2c" />
  9. <item name="shareSDKPlus_Wechat_AppSecret" value="c7253e5289986cf4c4c74d1ccc185fb1" />
  10. <item name="shareSDKPlus_Wechat_AppUniversalLink" value="https://www.sandslee.com/" />
  11. <item name="shareSDKPlus_Douyin_AppKey" value="aw9ivykfjvi4hpwo" />
  12. <item name="shareSDKPlus_Douyin_AppSecret" value="42b4caa6bda60bd49f05f06d0a4956e1" />
  13. <item name="shareSDKPlus_Facebook_AppKey" value="1412473428822331" />
  14. <item name="shareSDKPlus_Facebook_AppSecret" value="a42f4f3f867dc947b9ed6020c2e93558" />
  15. <item name="shareSDKPlus_Facebook_DisplayName" value="shareSDK" />
  16. <item name="shareSDKPlus_Twitter_AppKey" value="viOnkeLpHBKs6KXV7MPpeGyzE" />
  17. <item name="shareSDKPlus_Twitter_AppSecret" value="NJEglQUy2rqZ9Io9FcAU9p17omFqbORknUpRrCDOK46aAbIiey" />
  18. <item name="shareSDKPlus_Twitter_RedirectUri" value="http://mob.com" />
  19. <item name="shareSDKPlus_Instagram_AppKey" value="ff68e3216b4f4f989121aa1c2962d058" />
  20. <item name="shareSDKPlus_Instagram_AppSecret" value="1b2e82f110264869b3505c3fe34e31a1" />
  21. <item name="shareSDKPlus_Instagram_RedirectUri" value="http://sharesdk.cn" />
  22. <item name="shareSDKPlus_Google_AppKey" value="232554794995.apps.googleusercontent.com" />
  23. <item name="shareSDKPlus_Google_AppSecret" value="PEdFgtrMw97aCvf0joQj7EMk" />
  24. <item name="shareSDKPlus_Google_RedirectUri" value="http://localhost" />
  25. <item name="shareSDKPlus_Line_AuthType" value="2" />
  26. <item name="shareSDKPlus_AliPaySocial_AppKey" value="2017062107540437" />
  27. <item name="shareSDKPlus_MeiPai_AppKey" value="1089867639" />
  28. <item name="shareSDKPlus_DingTalk_AppKey" value="dingoabcwtuab76wy0kyzo" />
  29. <item name="shareSDKPlus_DouBan_AppKey" value="02e2cbe5ca06de5908a863b15e149b0b" />
  30. <item name="shareSDKPlus_DouBan_AppSecret" value="9f1e7b4f71304f2f" />
  31. <item name="shareSDKPlus_DouBan_RedirectUri" value="http://www.sharesdk.cn" />
  32. <item name="shareSDKPlus_TencentWeibo_AppKey" value="801307650" />
  33. <item name="shareSDKPlus_TencentWeibo_AppSecret" value="ae36f4ee3946e1cbb98d6965b0b2ff5c" />
  34. <item name="shareSDKPlus_TencentWeibo_RedirectUri" value="http://www.sharesdk.cn" />
  35. <item name="shareSDKPlus_YinXiang_AppKey" value="46131514-6903" />
  36. <item name="shareSDKPlus_YinXiang_AppSecret" value="08d7a6f3afcc888a" />
  37. <item name="shareSDKPlus_YinXiang_Sandbox" value="1" />
  38. <item name="shareSDKPlus_YouDaoNote_AppKey" value="dcde25dca105bcc36884ed4534dab940" />
  39. <item name="shareSDKPlus_YouDaoNote_AppSecret" value="d98217b4020e7f1874263795f44838fe" />
  40. <item name="shareSDKPlus_YouDaoNote_RedirectUri" value="http://www.sharesdk.cn/" />
  41. <item name="shareSDKPlus_Mingdao_AppKey" value="97230F25CA5C" />
  42. <item name="shareSDKPlus_Mingdao_AppSecret" value="A5DC29AF7C5A5851F28E903AE9EAC0" />
  43. <item name="shareSDKPlus_Mingdao_RedirectUri" value="http://mob.com" />
  44. <item name="shareSDKPlus_Kaixin_AppKey" value="358443394194887cee81ff5890870c7c" />
  45. <item name="shareSDKPlus_Kaixin_AppSecret" value="da32179d859c016169f66d90b6db2a23" />
  46. <item name="shareSDKPlus_Kaixin_RedirectUri" value="http://www.sharesdk.cn/" />
  47. <item name="shareSDKPlus_Renren_AppId" value="226427" />
  48. <item name="shareSDKPlus_Renren_AppKey" value="fc5b8aed373c4c27a05b712acba0f8c3" />
  49. <item name="shareSDKPlus_Renren_AppSecret" value="f29df781abdd4f49beca5a2194676ca4" />
  50. <item name="shareSDKPlus_Renren_AuthType" value="2" />
  51. <item name="shareSDKPlus_YiXin_AppKey" value="yx0d9a9f9088ea44d78680f3274da1765f" />
  52. <item name="shareSDKPlus_YiXin_AppSecret" value="1a5bd421ae089c3" />
  53. <item name="shareSDKPlus_YiXin_RedirectUri" value="https://open.yixin.im/resource/oauth2_callback.html" />
  54. <item name="shareSDKPlus_Kakao_AppKey" value="9c17eb03317e0e627ec95a400f5785fb" />
  55. <item name="shareSDKPlus_Kakao_ApiKey" value="802e551a5048c3172fc1dedaaf40fcf1" />
  56. <item name="shareSDKPlus_Kakao_RedirectUri" value="http://www.mob.com/oauth" />
  57. <item name="shareSDKPlus_YouTube_AppKey" value="906418427202-jinnbqal1niq4s8isbg2ofsqc5ddkcgr.apps.googleusercontent.com" />
  58. <item name="shareSDKPlus_YouTube_AppSecret" value="" />
  59. <item name="shareSDKPlus_YouTube_RedirectUri" value="http://localhost" />
  60. <item name="shareSDKPlus_Flickr_AppKey" value="cbed81d4a1bc7417693ab7865e354717" />
  61. <item name="shareSDKPlus_Flickr_AppSecret" value="4c490343869091f2" />
  62. <item name="shareSDKPlus_Dropbox_AppKey" value="us514wslpfojbxc" />
  63. <item name="shareSDKPlus_Dropbox_AppSecret" value="w0nmp4os3ngo1ja" />
  64. <item name="shareSDKPlus_Dropbox_RedirectUri" value="http://localhost" />
  65. <item name="shareSDKPlus_Evernote_AppKey" value="46131514-6903" />
  66. <item name="shareSDKPlus_Evernote_AppSecret" value="08d7a6f3afcc888a" />
  67. <item name="shareSDKPlus_Evernote_Sandbox" value="1" />
  68. <item name="shareSDKPlus_Pinterest_AppKey" value="4987008320438021391" />
  69. <item name="shareSDKPlus_Pocket_AppKey" value="11496-de7c8c5eb25b2c9fcdc2b627" />
  70. <item name="shareSDKPlus_Pocket_RedirectUri" value="pocketapp1234" />
  71. <item name="shareSDKPlus_LinkedIn_AppKey" value="46kic3zr7s4n" />
  72. <item name="shareSDKPlus_LinkedIn_AppSecret" value="RWw6WRl9YJOcdWsj" />
  73. <item name="shareSDKPlus_LinkedIn_RedirectUri" value="http://baidu.com" />
  74. <item name="shareSDKPlus_VKontakte_AppKey" value="5312801" />
  75. <item name="shareSDKPlus_VKontakte_AppSecret" value="ZHG2wGymmNUCRLG2r6CY" />
  76. <item name="shareSDKPlus_VKontakte_AuthType" value="2" />
  77. <item name="shareSDKPlus_Instapaper_AppKey" value="4rDJORmcOcSAZL1YpqGHRI605xUvrLbOhkJ07yO0wWrYrc61FA" />
  78. <item name="shareSDKPlus_Instapaper_AppSecret" value="GNr1GespOQbrm8nvd7rlUsyRQsIo3boIbMguAl9gfpdL0aKZWe" />
  79. <item name="shareSDKPlus_Tumblr_AppKey" value="2QUXqO9fcgGdtGG1FcvML6ZunIQzAEL8xY6hIaxdJnDti2DYwM" />
  80. <item name="shareSDKPlus_Tumblr_AppSecret" value="3Rt0sPFj7u2g39mEVB3IBpOzKnM3JnTtxX2bao2JKk4VV1gtNo" />
  81. <item name="shareSDKPlus_Tumblr_RedirectUri" value="http://sharesdk.cn" />
  82. <item name="shareSDKPlus_SMS_CountryList" value="0" />
  83. <item name="shareSDKPlus_CMCC_AppId" value="300011862498" />
  84. <item name="shareSDKPlus_CMCC_AppKey" value="38D9CA1CC280C5F207E2C343745D4A4B" />
  85. <item name="shareSDKPlus_CMCC_DisplayUI" value="1" />
  86. <item name="shareSDKPlus_Telegram_BotToken" value="646009290:AAGSonNPZqyjl0MUER8MdM8pwSPritFVNgI" />
  87. <item name="shareSDKPlus_Telegram_BotDomain" value="http://www.mob.com" />
  88. <item name="shareSDKPlus_Reddit_AppKey" value="ObzXn50T7Cg0Xw" />
  89. <item name="shareSDKPlus_Reddit_RedirectUri" value="https://www.mob.com/reddit_callback" />
  90. <item name="shareSDKPlus_ESurfing_AppKey" value="8148612606" />
  91. <item name="shareSDKPlus_ESurfing_AppSecret" value="mCltrhUqwshFa86egDTs0491ibaAulKA" />
  92. <item name="shareSDKPlus_ESurfing_AppName" value="shareSDK" />
  93. </security>

以上可能出现的全部各个平台的配置,根据开发者需要删减,另外部分特殊平台需要在info.plist文件中配置

字段描述:
shareSDKPlus_SinaWei_AppKey: 从新浪微博开放平台获取的App Key.
shareSDKPlus_SinaWei_AppSecret: 从新浪微博开放平台获取的App Secret.
shareSDKPlus_SinaWei_RedirectUri: 从新浪微博开放平台创建应用时 自定义填写的回调url
其他也是都是各自开放平台获取

配置info.plist文件 该文件含MOB平台MOBAppKey和MOBAppSecret、特殊平台appkey配置、白名单配置,将info.plist放在widget://res文件目录下,文件内容:

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
  3. <plist version="1.0">
  4. <dict>
  5. <key>MOBAppKey</key>
  6. <string>moba6b6c6d6</string>
  7. <key>MOBAppSecret</key>
  8. <string>b89d2427a3bc7ad1aea1e1e8c1d36bf3</string>
  9. <key>AccountKitClientToken</key>
  10. <string>c30c08723aa8c48fbd5e01d1c3103891</string>
  11. <key>FacebookAppID</key>
  12. <string>1412473428822331</string>
  13. <key>KAKAO_APP_KEY</key>
  14. <string>9c17eb03317e0e627ec95a400f5785fb</string>
  15. <key>LineSDKConfig</key>
  16. <dict>
  17. <key>ChannelID</key>
  18. <string>1521201864</string>
  19. </dict>
  20. <key>LSApplicationQueriesSchemes</key>
  21. <array>
  22. <string>weixinULAPI</string>
  23. <string>kakaotalk-5.9.7</string>
  24. <string>pinterestsdk.v1</string>
  25. <string>vkauthorize</string>
  26. <string>storylink</string>
  27. <string>kakaolink</string>
  28. <string>storykompassauth</string>
  29. <string>kakaokompassauth</string>
  30. <string>yixinfav</string>
  31. <string>yixinoauth</string>
  32. <string>yixinopenapi</string>
  33. <string>yixin</string>
  34. <string>pocket-oauth-v1</string>
  35. <string>dingtalk-open</string>
  36. <string>dingtalk</string>
  37. <string>alipayshare</string>
  38. <string>alipay</string>
  39. <string>whatsapp</string>
  40. <string>tim</string>
  41. <string>timapi</string>
  42. <string>timopensdkfriend</string>
  43. <string>timwpa</string>
  44. <string>timgamebindinggroup</string>
  45. <string>timapiwallet</string>
  46. <string>timOpensdkSSoLogin</string>
  47. <string>wtlogintim</string>
  48. <string>timopensdkgrouptribeshare</string>
  49. <string>timopensdkapiV4</string>
  50. <string>timgamebindinggroup</string>
  51. <string>timopensdkdataline</string>
  52. <string>wtlogintimV1</string>
  53. <string>timapiV1</string>
  54. <string>yixinoauth</string>
  55. <string>yixin</string>
  56. <string>sinaweibohd</string>
  57. <string>sinaweibo</string>
  58. <string>weibosdk2.5</string>
  59. <string>weibosdk</string>
  60. <string>weibo</string>
  61. <string>sinaweibosso</string>
  62. <string>weixin</string>
  63. <string>youtube</string>
  64. <string>mpsharesdk11</string>
  65. <string>mpsharesdk10</string>
  66. <string>mtmv</string>
  67. <string>mqqopensdkapiV4</string>
  68. <string>mqzone</string>
  69. <string>mqqwpa</string>
  70. <string>wtloginmqq2</string>
  71. <string>mqzoneopensdkapiV2</string>
  72. <string>mqzoneopensdkapi19</string>
  73. <string>mqzoneopensdkapi</string>
  74. <string>mqzoneopensdk</string>
  75. <string>mqqopensdkapiV3</string>
  76. <string>mqqopensdkapiV2</string>
  77. <string>mqq</string>
  78. <string>mqqOpensdkSSoLogin</string>
  79. <string>mqqapi</string>
  80. <string>lineauth</string>
  81. <string>line</string>
  82. <string>instagram</string>
  83. <string>fbauth</string>
  84. <string>fb-messenger-platform-20150714</string>
  85. <string>fb-messenger</string>
  86. <string>fbauth2</string>
  87. <string>fbapi</string>
  88. <string>fbapi20130214</string>
  89. <string>twitterauth</string>
  90. <string>tg</string>
  91. <string>telegram</string>
  92. <string>renrenapi</string>
  93. <string>renrenios</string>
  94. <string>renreniphone</string>
  95. <string>douyinsharesdk</string>
  96. <string>douyinopensdk</string>
  97. </array>
  98. <key>NSPhotoLibraryAddUsageDescription</key>
  99. <string>写入相册视频</string>
  100. <key>NSPhotoLibraryUsageDescription</key>
  101. <string>从手机相册中选择</string>
  102. <key>NSAppTransportSecurity</key>
  103. <dict>
  104. <key>NSAllowsArbitraryLoads</key>
  105. <true/>
  106. </dict>
  107. </dict>

MOBAppKey、MOBAppSecret:(必须配置)从mob平台创建应用后,申请的app Key和app Secret.
KAKAO_APP_KEY:从kaKao平台申请的 app Key,若iOS平台需要使用kaKaoTalk、kaKaoStory平台进行分享,必须添加此字段
LineSDKConfig:line平台配置
LSApplicationQueriesSchemes:白名单配置,用于判断是否安装第三方客户端及跳转到第三方客户端, 注意用到哪个就配置哪个,无用的可以不配置

注意:
配置白名单,也可以在配置config.xml文件中,配置方法参考配置可被检测的URL Scheme。配置内容参考mob官网
配置ATS(App Transport Security),在info.plist文件中,APP可以使用http协议访问。配置方法参考iOS修改Info.plist之配置ATS.

Android配置:

Mob-AppKey/Mob-AppSecret的配置: 这两个参数的配置在config.xml文件里,以meta-data标签的形式来配置,例如:

  1. <meta-data name="Mob-AppKey" value="moba6b6c6d6"/>
  2. <meta-data name="Mob-AppSecret" value="b89d2427a3bc7ad1aea1e1e8c1d36bf3"/>

Android配置第三方平台的AppKey等信息遵循APICloud的惯例是在config.xml中配置。 在name为”ShareSDKPlus”的标签内,配置标签来填充AppKey等属性的值。 下面是配置各个平台AppKey/AppSecret/RedirectUrl的例子,实际的使用中需要开发者填写自己在第三方网站申请的值(只需要改变值,不要改变AppKey/AppSecret/RedirectUrl的名称,否则将会读取不到)

  1. <feature name="shareSDKPlus">
  2. <param name="SinaWei_AppKey" value="568898243" />
  3. <param name="SinaWei_AppSecret" value="38a4f8204cc784f81f9f0daaf31e02e3" />
  4. <param name="SinaWei_RedirectUri" value="http://www.sharesdk.cn" />
  5. <param name="QQ_AppKey" value="100371282" />
  6. <param name="QQ_AppSecret" value="aed9b0303e3ed1e27bae87c33761161d" />
  7. <param name="Wechat_AppKey" value="wx4868b35061f87885" />
  8. <param name="Wechat_AppSecret" value="64020361b8ec4c99936c0e3999a9f249" />
  9. <param name="Wechat_AppUniversalLink" value="https://www.sandslee.com/" />
  10. <param name="Douyin_AppKey" value="aw9ivykfjvi4hpwo" />
  11. <param name="Douyin_AppSecret" value="42b4caa6bda60bd49f05f06d0a4956e1" />
  12. <param name="Facebook_AppKey" value="1412473428822331" />
  13. <param name="Facebook_AppSecret" value="a42f4f3f867dc947b9ed6020c2e93558" />
  14. <param name="Facebook_RedirectUrl" value="https://mob.com"/>
  15. <param name="Facebook_DisplayName" value="shareSDK" />
  16. <param name="FacebookMessage_AppKey" value="107704292745179" />
  17. <param name="Twitter_AppKey" value="viOnkeLpHBKs6KXV7MPpeGyzE" />
  18. <param name="Twitter_AppSecret" value="NJEglQUy2rqZ9Io9FcAU9p17omFqbORknUpRrCDOK46aAbIiey" />
  19. <param name="Twitter_RedirectUri" value="http://mob.com" />
  20. <param name="Instagram_AppKey" value="ff68e3216b4f4f989121aa1c2962d058" />
  21. <param name="Instagram_AppSecret" value="1b2e82f110264869b3505c3fe34e31a1" />
  22. <param name="Instagram_RedirectUri" value="http://sharesdk.cn" />
  23. <param name="Google_AppKey" value="232554794995.apps.googleusercontent.com" />
  24. <param name="Google_AppSecret" value="PEdFgtrMw97aCvf0joQj7EMk" />
  25. <param name="Google_RedirectUri" value="http://localhost" />
  26. <param name="Line_AppKey" value="1639219273" />
  27. <param name="Line_AppSecret" value="58faad55ffce8bf8f63b59fe6fb702ae" />
  28. <param name="Line_RedirectUri" value="https://www.mob.com/"/>
  29. <param name="Line_AuthType" value="2" />
  30. <param name="AliPaySocial_AppKey" value="2015072400185895" />
  31. <param name="MeiPai_AppKey" value="1089867596" />
  32. <param name="MeiPai_AppSecret" value="y9ym6rrjjijtkt23qtsc" />
  33. <param name="DingTalk_AppKey" value="dingoanxyrpiscaovl4qlw" />
  34. <param name="DouBan_AppKey" value="031a96a3aa8b28af094fc3eaffa17a0d" />
  35. <param name="DouBan_AppSecret" value="2e675e730571b75d" />
  36. <param name="DouBan_RedirectUri" value="http://mob.com" />
  37. <param name="TencentWeibo_AppKey" value="801307650" />
  38. <param name="TencentWeibo_AppSecret" value="ae36f4ee3946e1cbb98d6965b0b2ff5c" />
  39. <param name="TencentWeibo_RedirectUri" value="http://sharesdk.cn" />
  40. <param name="YinXiang_AppKey" value="sharesdk-7807" />
  41. <param name="YinXiang_AppSecret" value="d05bf86993836004" />
  42. <param name="YinXiang_HostType" value="sandbox" />
  43. <param name="YinXiang_Sandbox" value="1" />
  44. <param name="YouDaoNote_AppKey" value="dcde25dca105bcc36884ed4534dab940" />
  45. <param name="YouDaoNote_AppSecret" value="d98217b4020e7f1874263795f44838fe" />
  46. <param name="YouDaoNote_RedirectUri" value="http://www.sharesdk.cn/" />
  47. <param name="YouDaoNote_HostType" value="product" />
  48. <param name="Mingdao_AppKey" value="97230F25CA5C" />
  49. <param name="Mingdao_AppSecret" value="A5DC29AF7C5A5851F28E903AE9EAC0" />
  50. <param name="Mingdao_RedirectUri" value="http://mob.com" />
  51. <param name="Kaixin_AppKey" value="358443394194887cee81ff5890870c7c" />
  52. <param name="Kaixin_AppSecret" value="da32179d859c016169f66d90b6db2a23" />
  53. <param name="Kaixin_RedirectUri" value="http://www.sharesdk.cn/" />
  54. <param name="Renren_AppId" value="226427" />
  55. <param name="Renren_AppKey" value="fc5b8aed373c4c27a05b712acba0f8c3" />
  56. <param name="Renren_AppSecret" value="f29df781abdd4f49beca5a2194676ca4" />
  57. <param name="Renren_AuthType" value="2" />
  58. <param name="YiXin_AppKey" value="yx0d9a9f9088ea44d78680f3274da1765f" />
  59. <param name="YiXin_AppSecret" value="1a5bd421ae089c3" />
  60. <param name="YiXin_RedirectUri" value="https://open.yixin.im/resource/oauth2_callback.html" />
  61. <param name="Kakao_AppKey" value="48d3f524e4a636b08d81b3ceb50f1003" />
  62. <param name="Kakao_ApiKey" value="802e551a5048c3172fc1dedaaf40fcf1" />
  63. <param name="Kakao_RedirectUri" value="http://www.mob.com/oauth" />
  64. <param name="YouTube_AppKey" value="370141748022-bicrnsjfiije93bvdt63dh3728m4shas.apps.googleusercontent.com" />
  65. <param name="YouTube_AppSecret" value="AIzaSyAO06g-0TDpHcsXXO918a7QE3Zdct2bB5E" />
  66. <param name="YouTube_RedirectUri" value="http://localhost" />
  67. <param name="Flickr_ApiKey" value="33d833ee6b6fca49943363282dd313dd" />
  68. <param name="Flickr_ApiSecrett" value="3a2c5b42a8fbb8bb" />
  69. <param name="Flickr_RedirectUri" value="http://www.sharesdk.cn" />
  70. <param name="FourSquare_ApiKey" value="G0ZI20FM30SJAJTX2RIBGD05QV1NE2KVIM2SPXML2XUJNXEU" />
  71. <param name="FourSquare_ApiSecrett" value="3XHQNSMMHIFBYOLWEPONNV4DOTCDBQH0AEMVGCBG0MZ32XNU" />
  72. <param name="FourSquare_RedirectUri" value="http://www.sharesdk.cn" />
  73. <param name="Dropbox_AppKey" value="i5vw2mex1zcgjcj" />
  74. <param name="Dropbox_AppSecret" value="3i9xifsgb4omr0s" />
  75. <param name="Dropbox_RedirectUri" value="https://www.sharesdk.cn" />
  76. <param name="Evernote_AppKey" value="46131514-6903" />
  77. <param name="Evernote_AppSecret" value="08d7a6f3afcc888a" />
  78. <param name="Evernote_Sandbox" value="1" />
  79. <param name="Pinterest_AppKey" value="4987008320438021391" />
  80. <param name="Pocket_AppKey" value="11496-de7c8c5eb25b2c9fcdc2b627" />
  81. <param name="Pocket_RedirectUri" value="pocketapp1234" />
  82. <param name="LinkedIn_AppKey" value="46kic3zr7s4n" />
  83. <param name="LinkedIn_AppSecret" value="RWw6WRl9YJOcdWsj" />
  84. <param name="LinkedIn_RedirectUri" value="http://baidu.com" />
  85. <param name="VKontakte_AppKey" value="3921561" />
  86. <param name="VKontakte_AppSecret" value="ZHG2wGymmNUCRLG2r6CY" />
  87. <param name="VKontakte_AuthType" value="2" />
  88. <param name="Instapaper_AppKey" value="4rDJORmcOcSAZL1YpqGHRI605xUvrLbOhkJ07yO0wWrYrc61FA" />
  89. <param name="Instapaper_AppSecret" value="GNr1GespOQbrm8nvd7rlUsyRQsIo3boIbMguAl9gfpdL0aKZWe" />
  90. <param name="Tumblr_AppKey" value="2QUXqO9fcgGdtGG1FcvML6ZunIQzAEL8xY6hIaxdJnDti2DYwM" />
  91. <param name="Tumblr_AppSecret" value="3Rt0sPFj7u2g39mEVB3IBpOzKnM3JnTtxX2bao2JKk4VV1gtNo" />
  92. <param name="Tumblr_RedirectUri" value="http://www.sharesdk.cn" />
  93. <param name="SMS_CountryList" value="0" />
  94. <param name="CMCC_AppId" value="300011860247" />
  95. <param name="CMCC_AppKey" value="2D464D8BFCE73A44B4F9DF95A2FDBE1C" />
  96. <param name="CMCC_DisplayUI" value="1" />
  97. <param name="Telegram_BotToken" value="782826033" />
  98. <param name="Telegram_BotDomain" value="http://www.mob.com" />
  99. <param name="Reddit_AppKey" value="MExDxPuTCtFiRw" />
  100. <param name="Reddit_RedirectUri" value="http://www.sharesdk.cn" />
  101. <param name="Accountkit_AppKey" value="579465512480462" />
  102. <param name="Accountkit_AppSecret" value="8a6383652dd9f23fb0994f03d350d0ca" />
  103. <param name="Accountkit_RedirectUri" value="http://www.sharesdk.cn/" />
  104. <param name="ESurfing_AppKey" value="8148612606" />
  105. <param name="ESurfing_AppSecret" value="mCltrhUqwshFa86egDTs0491ibaAulKA" />
  106. <param name="ESurfing_RedirectUrl" value="http://www.sharesdk.cn"/>
  107. <param name="ESurfing_AppName" value="shareSDK" />
  108. </feature>

模块接口

首先添加一个ShareSDK.js内容如下:

  1. /**
  2. * 常量:分享类型,分享/授权平台,分享/授权结果状态
  3. */
  4. function ShareSDK()
  5. {
  6. /**
  7. * JSON字符串转换为对象
  8. * @param string JSON字符串
  9. * @returns {Object} 转换后对象
  10. */
  11. JsonStringToObject = function (string)
  12. {
  13. try
  14. {
  15. return eval("(" + string + ")");
  16. }
  17. catch (err)
  18. {
  19. return null;
  20. }
  21. };
  22. this.JsonStringToObject = function (string)
  23. {
  24. return JsonStringToObject(string);
  25. }
  26. /**
  27. * 对象转JSON字符串
  28. * @param obj 对象
  29. * @returns {string} JSON字符串
  30. */
  31. ObjectToJsonString = function (obj)
  32. {
  33. var S = [];
  34. var J = null;
  35. var type = Object.prototype.toString.apply(obj);
  36. if (type === '[object Array]')
  37. {
  38. for (var i = 0; i < obj.length; i++)
  39. {
  40. S.push(ObjectToJsonString(obj[i]));
  41. }
  42. J = '[' + S.join(',') + ']';
  43. }
  44. else if (type === '[object Date]')
  45. {
  46. J = "new Date(" + obj.getTime() + ")";
  47. }
  48. else if (type === '[object RegExp]'
  49. || type === '[object Function]')
  50. {
  51. J = obj.toString();
  52. }
  53. else if (type === '[object Object]')
  54. {
  55. for (var key in obj)
  56. {
  57. var value = ObjectToJsonString(obj[key]);
  58. if (value != null)
  59. {
  60. S.push('"' + key + '":' + value);
  61. }
  62. }
  63. J = '{' + S.join(',') + '}';
  64. }
  65. else if (type === '[object String]')
  66. {
  67. J = '"' + obj.replace(/\\/g, '\\\\').replace(/"/g, '\\"').replace(/\n/g, '') + '"';
  68. }
  69. else if (type === '[object Number]')
  70. {
  71. J = obj;
  72. }
  73. else if (type === '[object Boolean]')
  74. {
  75. J = obj;
  76. }
  77. return J;
  78. };
  79. this.ObjectToJsonString = function (obj)
  80. {
  81. return ObjectToJsonString(obj);
  82. }
  83. /**
  84. * 平台类型
  85. * @type {object}
  86. */
  87. this.PlatformID = {
  88. Unknown : 0,
  89. SinaWeibo : 1, //Sina Weibo
  90. TencentWeibo : 2, //Tencent Weibo
  91. DouBan : 5, //Dou Ban
  92. QZone : 6, //QZone
  93. Renren : 7, //Ren Ren
  94. Kaixin : 8, //Kai Xin
  95. Pengyou : 9, //Friends
  96. Facebook : 10, //Facebook
  97. Twitter : 11, //Twitter
  98. Evernote : 12, //Evernote
  99. Foursquare : 13, //Foursquare
  100. GooglePlus : 14, //Google+
  101. Instagram : 15, //Instagram
  102. LinkedIn : 16, //LinkedIn
  103. Tumblr : 17, //Tumblr
  104. Mail : 18, //Mail
  105. SMS : 19, //SMS
  106. Print : 20, //Print
  107. Copy : 21, //Copy
  108. WeChat : 22, //WeChat Friends
  109. WeChatMoments : 23, //WeChat Timeline
  110. QQ : 24, //QQ
  111. Instapaper : 25, //Instapaper
  112. Pocket : 26, //Pocket
  113. YouDaoNote : 27, //You Dao Note
  114. Pinterest : 30, //Pinterest
  115. Flickr : 34, //Flickr
  116. Dropbox : 35, //Dropbox
  117. VKontakte : 36, //VKontakte
  118. WeChatFavorites : 37, //WeChat Favorited
  119. YiXinSession : 38, //YiXin Session
  120. YiXinTimeline : 39, //YiXin Timeline
  121. YiXinFav : 40, //YiXin Favorited
  122. MingDao : 41, //明道
  123. Line : 42, //Line
  124. WhatsApp : 43, //Whats App
  125. KakaoTalk : 44, //KakaoTalk
  126. KakaoStory : 45, //KakaoStory
  127. FacebookMessenger : 46, //FacebookMessenger
  128. Bluetooth : 48, //Bluetooth
  129. Alipay : 50, //Alipay
  130. AliPaySocialTimeline:51,//AliPaySocial Timeline
  131. DingTalk:52, //DingTalk
  132. YouTube:53, //youtube
  133. MeiPai:54, //美拍
  134. Cmcc : 55, //中国移动
  135. Reddit : 56, //Reddit
  136. ESurfing : 57, //天翼
  137. Douyin : 58, //抖音
  138. FacebookAccount : 58, //FacebookAccount
  139. KakaoPlatform : 995, //Kakao Series
  140. EvernotePlatform : 996, //Evernote Series
  141. WechatPlatform : 997, //Wechat Series
  142. QQPlatform : 998, //QQ Series
  143. Any : 999 //Any Platform
  144. };
  145. /**
  146. * 回复状态
  147. * @type {object}
  148. */
  149. this.ResponseState = {
  150. Begin : 0, //开始
  151. Success: 1, //成功
  152. Fail : 2, //失败
  153. Cancel : 3 //取消
  154. };
  155. /**
  156. * 内容分享类型
  157. * @type {object}
  158. */
  159. this.ContentType = {
  160. Auto : 0,
  161. Text : 1,
  162. Image : 2,
  163. WebPage : 4,
  164. Music : 5,
  165. Video : 6,
  166. App : 7,
  167. File : 8,
  168. Emoji : 9
  169. };
  170. };
  171. var $sharesdk = new ShareSDK();

添加ShareSDK.js目的主要是提供平台号,回调状态等一些常量

引入模块

  1. var shareApi = api.require('shareSDKPlus');

authorize

授权
authorize({params}, callback(ret, err))

params

platform:

  • 类型:数字
  • 描述:授权平台号,是新浪微博授权还是微信授权或者其他平台授权,由此参数决定

callback(ret, err)

ret:

  • 类型:JSON 对象
  • 内部字段:
  1. {
  2. state: 1 //数字类型,1:成功 2:失败 3:取消
  3. data:{} //json对象 授权后获取的用户信息
  4. error:{ // state = 2时
  5. error_code:, //错误码
  6. error_msg: //错误信息
  7. }
  8. }

示例代码

  1. var shareApi = api.require('shareSDKPlus');
  2. shareApi.authorize({
  3. "platform": $sharesdk.PlatformID.SinaWeibo
  4. },function(ret, err){
  5. var state = ret.state;
  6. switch(state)
  7. {
  8. case $sharesdk.ResponseState.Success://1
  9. api.toast({
  10. msg: "授权成功",
  11. location: 'middle'
  12. });
  13. break;
  14. case $sharesdk.ResponseState.Fail://2
  15. api.toast({
  16. msg: "授权失败",
  17. location: 'middle'
  18. });
  19. break;
  20. case $sharesdk.ResponseState.Cancel://3
  21. api.toast({
  22. msg: "取消授权",
  23. location: 'middle'
  24. });
  25. break;
  26. default:
  27. }
  28. });

可用性

iOS系统,Android系统

可提供的1.0.0及更高版本

cancelAuthorize

取消授权
cancelAuthorize({params}, callback(ret, err))

params

platform:

  • 类型:数字
  • 描述:授权平台号

callback(ret, err)

ret:

  • 类型:JSON 对象
  • 内部字段:
  1. {
  2. state: 1 //数字类型,1:成功 2:失败 3:取消
  3. error:{ // state = 2时
  4. error_code:, //错误码
  5. error_msg: //错误信息
  6. }
  7. }

示例代码

  1. var shareApi = api.require('shareSDKPlus');
  2. shareApi.cancelAuthorize({
  3. "platform": $sharesdk.PlatformID.SinaWeibo
  4. },function(ret, err){
  5. var state = ret.state;
  6. switch(state)
  7. {
  8. case $sharesdk.ResponseState.Success://1
  9. api.toast({
  10. msg: "成功",
  11. location: 'middle'
  12. });
  13. break;
  14. case $sharesdk.ResponseState.Fail://2
  15. api.toast({
  16. msg: "失败",
  17. location: 'middle'
  18. });
  19. break;
  20. case $sharesdk.ResponseState.Cancel://3
  21. api.toast({
  22. msg: "授权",
  23. location: 'middle'
  24. });
  25. break;
  26. default:
  27. }
  28. });

可用性

iOS系统,Android系统

可提供的1.0.0及更高版本

getUserInfo

获取用户信息
getUserInfo({params}, callback(ret, err))

params

platform:

  • 类型:数字
  • 描述:平台号,是获取新浪微博还是微信或者其他平台用户信息,由此参数决定

callback(ret, err)

ret:

  • 类型:JSON 对象
  • 内部字段:
  1. {
  2. state: 1 //数字类型,1:成功 2:失败 3:取消
  3. data:{} //json对象 获取的用户信息
  4. error:{ // state = 2时
  5. error_code:, //错误码
  6. error_msg: //错误信息
  7. }
  8. }

示例代码

  1. var shareApi = api.require('shareSDKPlus');
  2. shareApi.getUserInfo({
  3. "platform": $sharesdk.PlatformID.SinaWeibo
  4. },function(ret, err){
  5. var state = ret.state;
  6. switch(state)
  7. {
  8. case $sharesdk.ResponseState.Success://1
  9. api.toast({
  10. msg: "成功",
  11. location: 'middle'
  12. });
  13. break;
  14. case $sharesdk.ResponseState.Fail://2
  15. api.toast({
  16. msg: "失败",
  17. location: 'middle'
  18. });
  19. break;
  20. case $sharesdk.ResponseState.Cancel://3
  21. api.toast({
  22. msg: "取消",
  23. location: 'middle'
  24. });
  25. break;
  26. default:
  27. }
  28. });

可用性

iOS系统,Android系统

可提供的1.0.0及更高版本

shareContent

分享
shareContent({params}, callback(ret, err))

params

platform:

  • 类型:数字
  • 描述:平台号,分享到指定平台

shareParams:

  • 类型:json
  • 描述:分享内容
    • text:文本
    • imageUrl:图片地址
    • title:标题
    • type:分享类型:分享文本、分享图片、分享链接等等

callback(ret, err)

ret:

  • 类型:JSON 对象
  • 内部字段:
  1. {
  2. state: 1 //数字类型,1:成功 2:失败 3:取消
  3. data:{} //
  4. error:{ // state = 2时
  5. error_code:, //错误码
  6. error_msg: //错误信息
  7. }
  8. }

示例代码

  1. var shareApi = api.require('shareSDKPlus');
  2. var shareParams =
  3. {
  4. "text" : "测试的文字",
  5. "imageUrl" : "http://download.sdk.mob.com/206/4f8/dfc9ea27dd8bc4abfec865c38d/800_450_156.2.jpg",
  6. "title" : "测试的标题",
  7. "titleUrl" : "http://www.mob.com",
  8. "description" : "测试的描述",
  9. "site" : "ShareSDK",
  10. "siteUrl" : "http://www.mob.com",
  11. "type" : $sharesdk.ContentType.Auto
  12. };
  13. shareApi.shareContent({
  14. "platform": $sharesdk.PlatformID.SinaWeibo,
  15. "shareParams": shareParams
  16. },function(ret, err){
  17. var state = ret.state;
  18. switch(state)
  19. {
  20. case $sharesdk.ResponseState.Success://1
  21. api.toast({
  22. msg: "分享成功",
  23. location: 'middle'
  24. });
  25. break;
  26. case $sharesdk.ResponseState.Fail://2
  27. api.toast({
  28. msg: "分享失败",
  29. location: 'middle'
  30. });
  31. break;
  32. case $sharesdk.ResponseState.Cancel://3
  33. api.toast({
  34. msg: "取消分享",
  35. location: 'middle'
  36. });
  37. break;
  38. default:
  39. }
  40. });

可用性

iOS系统,Android系统

可提供的1.0.0及更高版本

oneKeyShareContent

一键分享/菜单分享 oneKeyShareContent({params}, callback(ret, err))

params

platforms:

  • 类型:数组
  • 描述:可分享的平台列表,为null为全平台

shareParams:

  • 类型:json
  • 描述:分享内容
    • text:文本
    • imageUrl:图片地址
    • title:标题
    • type:分享类型:分享文本、分享图片、分享链接等等

callback(ret, err)

ret:

  • 类型:JSON 对象
  • 内部字段:
  1. {
  2. state: 1 //数字类型,1:成功 2:失败 3:取消
  3. data:{} //
  4. error:{ // state = 2时
  5. error_code:, //错误码
  6. error_msg: //错误信息
  7. }
  8. }

示例代码

  1. var shareApi = api.require('shareSDKPlus');
  2. var shareParams =
  3. {
  4. "text" : "测试的文字",
  5. "imageUrl" : "http://download.sdk.mob.com/206/4f8/dfc9ea27dd8bc4abfec865c38d/800_450_156.2.jpg",
  6. "title" : "测试的标题",
  7. "titleUrl" : "http://www.mob.com",
  8. "description" : "测试的描述",
  9. "site" : "ShareSDK",
  10. "siteUrl" : "http://www.mob.com",
  11. "type" : $sharesdk.ContentType.Auto
  12. };
  13. var platforms =
  14. [
  15. $sharesdk.PlatformID.SinaWeibo,
  16. $sharesdk.PlatformID.WeChat
  17. ];
  18. shareApi.oneKeyShareContent({
  19. "platforms": platforms, //为null时,显示全部可分享的平台(排除当前环境不可分享平台)
  20. "shareParams": shareParams
  21. },function(ret, err){
  22. var state = ret.state;
  23. switch(state)
  24. {
  25. case $sharesdk.ResponseState.Success://1
  26. api.toast({
  27. msg: "分享成功",
  28. location: 'middle'
  29. });
  30. break;
  31. case $sharesdk.ResponseState.Fail://2
  32. api.toast({
  33. msg: "分享失败",
  34. location: 'middle'
  35. });
  36. break;
  37. case $sharesdk.ResponseState.Cancel://3
  38. api.toast({
  39. msg: "取消分享",
  40. location: 'middle'
  41. });
  42. break;
  43. default:
  44. }
  45. });

可用性

iOS系统,Android系统

可提供的1.0.0及更高版本

如何扩充平台

当前shareSDKPlus只支持微信、QQ、新浪微博、facebook、twitter五个平台,如果想要支持其他平台应如何操作

iOS方案

点击此处

android方案

点击此处