Github.com/czy1121/sdk… Reezy. Me / 2017-03-31 /…

Third-party SDK integration library, supporting authorization, sharing, payment and other functions

  • Authorization currently supports wechat /QQ/ Sina Weibo, the client only needs to configure APPID(Sina Weibo).
  • Sharing currently supports wechat (session/circle of friends/collection), QQ/QZone, Sina Weibo
  • Alipay currently supports Alipay/wechat Pay
  • For authorization and sharing, the client does not need to configure APPSECRET, but only APPID(Sina Weibo authorization requires redirectUrl).
  • For payments, the APPID is contained in payData dynamically returned by the back end
  • Custom platform implementations can be registered to meet special needs
  • Sharing does not implement the UI; you need to provide your own UI

At present, this library is not stable, some details have not been carefully considered, some functions have not been tested, and there are not many supported platforms. Welcome everyone star/ Issue/PR to improve this library together

About the authorization

The success of the result to “code | {code}”, “token | {openId} | {token}” two forms

  • Wechat authorization is the authorization code returned by OAuth2.0.
  • QQ authorization is SSO returns token
  • Weibo licenses its documentation to support SSO and OAuth2.0, depending on the situation may return code and token

However, the client does not need to care about the code or token, just send the result to the server

About the payment

Many payment libraries process the payment information on the client side, which is not necessary. The server returns the data to the payment SDK and processes the payment result

On sharing

Support text, image, text, web page, music, video and other types of sharing

  • Page/music/video is in card form, you can add title/description/thumbnail.
  • Description is not displayed in wechat moments
  • The url contained in the sina Weibo post will be converted into a link
  • QZone’s text/pictures/texts/videos will be published in the form of “talk”
platform Plain text Pure image graphic Web page music video
QQ x o x o o x
QZone o o o o x o
WXSession o o x o o o
WXTimeline o o x o o o
Weibo o o o x x x

Method of use

Add the dependent

repositories {
    maven { url "https://jitpack.io" }
}
dependencies {
    compile 'com. Making. Czy1121: sdk3rd: 0.1.0 from'
}Copy the code

or

repositories {
    maven { url "https://jitpack.io" }
}
dependencies {
    compile 'com. Making. Czy1121. Sdk3rd: sdk3rd: 0.1.0 from'
    compile 'com. Making. Czy1121. Sdk3rd: sdk3rd - alipay: 0.1.0 from'
    compile 'com. Making. Czy1121. Sdk3rd: sdk3rd - qq: 0.1.0 from'
}Copy the code

Using a configuration

Configuration APPID


PlatformConfig.useQQ(BuildConfig.APPID_QQ);
PlatformConfig.useWeixin(BuildConfig.APPID_WEIXIN);
PlatformConfig.useWeibo(BuildConfig.APPID_WEIBO, "http://www.sina.com/");
PlatformConfig.usePayments();Copy the code

Using the Licensed SDK

Setting global event callback (optional)

AuthorizeSDK.setDefaultCallback(new OnCallback() {
    @Override
    public void onStarted(Activity activity) {
        Log.e("ezy"."authorize started");
    }

    @Override
    public void onCompleted(Activity activity) {
        Log.e("ezy"."authorize completed");
    }

    @Override
    public void onSucceed(Activity activity, Object result) {
        Log.e("ezy"."authorize succeed");
    }

    @Override
    public void onFailed(Activity activity, int code, String message) {
        Log.e("ezy"."authorize failed [" + code + "]"+ message); }});Copy the code

Receiving authorization result (Sina Weibo /QQ)

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    AuthorizeSDK.onHandleResult(this, requestCode, resultCode, data);
}Copy the code

Call the authorization

AuthorizeSDK.authorize(MainActivity.this, platform, new OnSucceed<String>() {
    @Override
    public void onSucceed(String result) {
        Toast.makeText(MainActivity.this."Successful landing -"+ result, Toast.LENGTH_LONG).show(); }});Copy the code

Register custom platform, need to implement IAuthorize and corresponding IFactory

AuthorizeSDK.register(IFactory<IAuthorize> factory);
AuthorizeSDK.register(String platformName, String appId, Class<IAuthorize> clazz);Copy the code

Using the Payment SDK

The setup for global event callbacks is similar to the authorization SDK

Call to pay

PaymentSDK.pay(MainActivity.this, platform, paydata, new OnSucceed<String>() {
    @Override
    public void onSucceed(String result) {
        // todo}});Copy the code

To register a custom platform, you need to implement IPayable and the corresponding IFactory

PaymentSDK.register(IFactory<IPayable> factory);
PaymentSDK.register(String platformName, Class<IPayable> clazz);Copy the code

Using the Sharing SDK

The setup for global event callbacks is similar to the authorization SDK

.

The reception of sharing results is also similar to authorized SDK (QQ)

.

To register a custom platform, you need to implement IShareable and the corresponding IFactory

ShareSDK.register(IFactory<IShareable> factory);
ShareSDK.register(String platformName, String appId, Class<IShareable> clazz);Copy the code

share

// Share plain text
ShareSDK.make(this, text).share(platform);
// Share pure images
ShareSDK.make(this.new MoImage(image)).share(platform);
// Share the text
ShareSDK.make(this, text, new MoImage(image)).share(platform);

// Share web links
ShareSDK.make(this.new MoWeb(url))
        .withTitle("Here's the title.")
        .withDescription("Here's the abstract.")
        .withThumb(thumb)
        .share(platform, new OnSucceed<String>() {
           @Override
           public void onSucceed(String result) {
               Toast.makeText(MainActivity.this."Share the success", Toast.LENGTH_LONG).show(); }});// Share music
ShareSDK.make(this.new MoMusic(url))
        .withTitle("Here's the title.")
        .withDescription("Here's the abstract.")
        .withThumb(thumb)
        .share(platform);Copy the code

reference

Umeng + Share 90% FaQs bbs.umeng.com/thread-1776…

Their Allies the platform can share content preview dev.umeng.com/social/andr…

… wiki.mob.com/…