ShareLoginLib
repository·master·Indexed 20 days ago
https://github.com/lingochamp/shareloginlibAn Android utility library for sharing images, text, or music and implementing social logins for WeChat, Weibo, and QQ. It provides managers for WeChat sharing and login, and supports both local and remote image sharing for WeChat and QQ Space.
What's inside shareloginlib
- The library supports both local and remote image sharing specifically for WeChat and QQ Space. For all other platforms/integrations supported by the library, only local image sharing is available.
Include ShareLoginLib in your project
masterAdd the following dependency to your
build.gradlefile to include ShareLoginLib in your Android project.compile 'com.echodjb.shareloginlib:share:0.6'Perform WeChat login
masterTo implement WeChat login, use
WechatLoginManagerand provide aPlatformActionListenerto handle the login lifecycle:onComplete(returns user info in aHashMap<String, Object>),onError, andonCancel.ILoginManager iLoginManager = new WechatLoginManager(MainActivity.this); iLoginManager.login(new PlatformActionListener() { @Override public void onComplete(HashMap<String, Object> userInfo) { // Handle successful login with userInfo } @Override public void onError() { // Handle error } @Override public void onCancel() { // Handle user cancellation } });Initialize the Weibo redirect URL
masterTo handle Weibo authentication callbacks correctly, initialize the redirect URL using
ShareBlock.getInstance().initWeiboRedriectUrl().ShareBlock.getInstance().initWeiboRedriectUrl(weiboRedriectUrl);Share content to WeChat
masterTo share content to WeChat, instantiate a
WechatShareManagerand call thesharemethod with aShareContentWebpageobject. You can specify the share type usingWechatShareManager.WEIXIN_SHARE_TYPE_TALK.IShareManager iShareManager = new WechatShareManager(context); iShareManager.share(new ShareContentWebpage("title", "content", "dataUrl", "imageUrl", WechatShareManager.WEIXIN_SHARE_TYPE_TALK));Initialize ShareLoginLib with third-party keys
masterBefore using sharing or login features, you must initialize the library with your application credentials for WeChat, Weibo, and QQ using
ShareBlock.getInstance().initShare().ShareBlock.getInstance().initShare(wechatAppid, weiboId, qqId, wechatSecret);