All Projects → laughfly → Rxsociallib

laughfly / Rxsociallib

Licence: mit
分享登录工具库,简洁配置,可配合RxJava/RxJava2使用,支持QQ微信微博

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Rxsociallib

Auth
Authenticator via oauth2
Stars: ✭ 118 (+686.67%)
Mutual labels:  library, login
YHThirdManager
一个快速、简单、易集成、扩展性好的社交化组件。摒弃友盟等三方库,使用原生SDK。支持微信支付、微信分享、微信登录、微信授权、QQ授权、QQ分享、QQ登录、新浪授权、新浪登录、新浪分享、微博评论、微博获取、支付宝支付。极大的减小了包体积;同时加入了自动管理提示框的功能
Stars: ✭ 41 (+173.33%)
Mutual labels:  share, login
Sdk3rd
第三方SDK集成库,授权/分享/支付
Stars: ✭ 249 (+1560%)
Mutual labels:  share, login
Wechat kit
flutter版微信登录/分享/支付
Stars: ✭ 347 (+2213.33%)
Mutual labels:  share, login
tencent kit
flutter版QQ登录/分享
Stars: ✭ 201 (+1240%)
Mutual labels:  share, login
Socialsdklibrary
提供微博、微信、QQ、Tim、QQ 轻聊版、钉钉的登陆分享功能支持;
Stars: ✭ 399 (+2560%)
Mutual labels:  share, login
Gitter Api
[production-ready] Gitter API implementation for php 7.0+ allowing sync, async and streaming access.
Stars: ✭ 11 (-26.67%)
Mutual labels:  library
Printcess
Haskell pretty printing library supporting indentation, mixfix operators, and automatic line breaks.
Stars: ✭ 13 (-13.33%)
Mutual labels:  library
Parallel Ssh
Asynchronous parallel SSH client library.
Stars: ✭ 864 (+5660%)
Mutual labels:  library
Genus
A general code generation tools for Go applications
Stars: ✭ 11 (-26.67%)
Mutual labels:  library
Vue Echarts V3
Vue.js(v2.x+) component wrap for ECharts.js(v3.x+)
Stars: ✭ 884 (+5793.33%)
Mutual labels:  library
Cordova Plugin Camera
Apache Cordova Plugin camera
Stars: ✭ 879 (+5760%)
Mutual labels:  library
Werender
Simple, light-weight, Canvas library for 2D rendering
Stars: ✭ 13 (-13.33%)
Mutual labels:  library
Tabulate
Table Maker for Modern C++
Stars: ✭ 862 (+5646.67%)
Mutual labels:  library
Omgl
Pythonic OpenGL Bindings
Stars: ✭ 13 (-13.33%)
Mutual labels:  library
Joctomap
Java/Android wrapper for Octomap: an octree-based mapping library
Stars: ✭ 11 (-26.67%)
Mutual labels:  library
Polysnap
A work in progress polygon operations library with integer snap-rounding
Stars: ✭ 14 (-6.67%)
Mutual labels:  library
Awareness
The new architecture of co-computation for data processing and machine learning.
Stars: ✭ 11 (-26.67%)
Mutual labels:  library
Egjs
Javascript components group that brings easiest and fastest way to build a web application in your way.
Stars: ✭ 871 (+5706.67%)
Mutual labels:  library
Androidlibs
🔥正在成为史上最全分类 Android 开源大全~~~~(长期更新 Star 一下吧)
Stars: ✭ 7,148 (+47553.33%)
Mutual labels:  library

RxSocialLib

  • 支持QQ,QQZone,微信,微信朋友圈,微博,微博故事,Google登录
  • 兼容RxJava/RxJava2数据流
  • 基于平台的官方SDK开发

导入

在根目录下的build.gradle文件添加

buildscript {
    dependencies {
        classpath 'com.laughfly.rxsociallib:plugin:0.3.5.0'
    }
}

使用

在全局初始化的位置调用

    RxSocial.initialize(context);

分享

    RxSocial.shareBuilder()
            //SharePlatform根据配置文件自动生成
            .setPlatform(SharePlatform.Wechat)
            .setTitle("标题")
            .setText("内容")
            .setThumbUri("图标地址")
            //分享网页
            .setWebUrl("https://www.github.com")
            //分享图片
            .setImageUri("https://sample-videos.com/img/Sample-jpg-image-500kb.jpg")
            //分享音频
            .setAudioUri("https://sample-videos.com/audio/mp3/wave.mp3")
            //分享视频
            .setVideoUri("/storage/emulated/0/Download/test.mp4")
            //分享文件
            .setFileUri("本地文件路径")
            //分享微信小程序
            .setMiniProgramPath("微信小程序地址")
            .setMiniProgramType(SocialConstants.MINIPROGRAM_TYPE_RELEASE)
            .setMiniProgramUserName("user")
            .build()
            //分享结果回调
            .start(new SocialCallback<ShareParams, SocialShareResult>() {
               
                @Override
                public void onError(String platform, ShareParams shareParams, SocialException e) {
                    Toast.makeText(MainActivity.this, "分享失败: " + e.getErrCode(), Toast.LENGTH_SHORT).show();
                }
            
                @Override
                public void onSuccess(String platform, ShareParams shareParams, SocialShareResult resp) {
                    Toast.makeText(MainActivity.this, "分享成功", Toast.LENGTH_SHORT).show();
                }
            })
            //to RxJava Observable
            .toObservable()
            //to RxJava2 Observable
            .toObservable2()
            //to RxJava2 Flowable
            .toFlowable()

登录

        RxSocial.loginBuilder()
            //LoginPlatform根据配置文件自动生成
            .setPlatform(LoginPlatform.Wechat)
            .setClearLastAccount(boolean)//清除上次保存的账号
            .setSaveAccessToken(boolean)//保存AccessToken
            .setLogoutOnly(boolean)//注销
            .setServerSideMode(boolean)//ServerSideMode,返回ServerAuthCode
            .setFetchUserProfile(boolean)//获取更详细的用户信息
            .start(new SocialCallback<LoginParams, SocialLoginResult>() {
                @Override
                public void onError(String platform, LoginParams loginParams, SocialException e) {
                    Toast.makeText(MainActivity.this, "登录失败: " + e.getErrCode(), Toast.LENGTH_SHORT).show();
                }

                @Override
                public void onSuccess(String platform, LoginParams loginParams, SocialLoginResult resp) {
                    Toast.makeText(MainActivity.this, "登录成功\nuid: " + socialLoginResult.uid, Toast.LENGTH_SHORT).show();
                }
            })
            .build()
            //to RxJava Observable
            .toObservable()
            //to RxJava2 Observable
            .toObservable2()
            //to RxJava2 Flowable
            .toFlowable()

配置

参照sample下的social-config.gradle文件进行平台配置,只有写在配置里的平台的依赖包会被导入。

apply plugin: 'social-config'

RxSocialConfig{
    Weibo {
        appId 'yourAppId'
        appSecret 'yourAppSecret'
        redirectUrl 'https://api.weibo.com/oauth2/default.html'
        scope 'get_token_info'
    }
    WeiboStory {
        appId 'yourAppId'
        appSecret 'yourAppSecret'
        redirectUrl 'https://api.weibo.com/oauth2/default.html'
        login false
    }
    QQ {
        appId 'yourAppId'
        appSecret 'yourAppSecret'
        scope 'get_simple_userinfo'
    }
    QQZone {
        appId 'yourAppId'
        login false
    }
    Wechat {
        appId 'yourAppId'
        appSecret 'yourAppSecret'
        scope 'snsapi_userinfo'
        state 'wechat_sdk_live'
    }
    WechatMoments {
        appId 'yourAppId'
        login false
    }
}

然后在你的app的build.gradle里添加

apply from:'social-config.gradle'

刷新,完成!

RxJava/RxJava2

library对RxJava/RxJava2的依赖用的scope是compileOnly,所以最终生成apk里不会有多余的RxJava/RxJava2库。 支持的RxJava版本是1.2.7。 另外需要自己添加对RxJava/RxJava2的依赖。

其他

修改social-config.gradle里的平台信息后可能需要Rebuild Project才有效果!

TO DO

使用插件简化平台配置
分离平台实现代码
添加更多平台

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].