Third-party SDK integration library supports authorization/sharing/payment and other functions
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. Everyone is welcome to star/issue/pr and work together to improve this library.
The result after success is in two forms: "code|{code}" and "token|{openId}|{token}"
But the client doesn’t actually need to care whether it’s a code or a token, it can just send the result directly to the server.
Many payment libraries will process product payment information on the client side. In fact, this is unnecessary. The server can directly return the data and hand it over to the payment SDK, and then process the payment results.
Supports sharing types such as plain text/pure pictures/graphics/webpages/music/videos
platform | plain text | Pure pictures | Graphics and text | Web page | music | video |
---|---|---|---|---|---|---|
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 |
o | o | o | x | x | x | |
SendToQQ | o | o | x | x | x | x |
SendToWXS | o | o | x | x | x | x |
SendToWXT | o | o | x | x | x | x |
To run the demo, you need to modify the app's package name, signature and APPID applied for the app in gradle.properties
APPLICATION_ID=ezy.demo.sdk3rd
APPID_QQ=YOUR_APPID
APPID_WEIXIN=YOUR_APPID
APPID_WEIBO=YOUR_APPID
SINGING_ALIAS=androiddebugkey
SINGING_PASSWORD=android
SINGING_FILE=debug.keystore
repositories {
maven { url " https://jitpack.io " }
}
dependencies {
compile ' com.github.czy1121.sdk3rd:sdk3rd:0.1.2 '
compile ' com.github.czy1121.sdk3rd:sdk3rd-alipay:0.1.1 '
compile ' com.github.czy1121.sdk3rd:sdk3rd-qq:0.1.0 '
compile ' com.sina.weibo.sdk:core:1.0.0:openDefaultRelease@aar '
compile ' com.tencent.mm.opensdk:wechat-sdk-android-without-mta:1.0.2 '
}
Configure APPID
PlatformConfig . useQQ ( BuildConfig . APPID_QQ );
PlatformConfig . useWeixin ( BuildConfig . APPID_WEIXIN );
PlatformConfig . useWeibo ( BuildConfig . APPID_WEIBO , "http://www.sina.com/" );
PlatformConfig . usePayments ();
Set global event callback (not necessary)
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 );
}
});
Receive authorization results (Sina Weibo/QQ)
@ Override
protected void onActivityResult ( int requestCode , int resultCode , Intent data ) {
super . onActivityResult ( requestCode , resultCode , data );
AuthorizeSDK . onHandleResult ( this , requestCode , resultCode , data );
}
call authorization
AuthorizeSDK . authorize ( MainActivity . this , platform , new OnSucceed < String >() {
@ Override
public void onSucceed ( String result ) {
Toast . makeText ( MainActivity . this , "登陆成功 - " + result , Toast . LENGTH_LONG ). show ();
}
});
To register a custom platform, you need to implement IAuthorize and the corresponding IFactory
AuthorizeSDK . register ( IFactory < IAuthorize > factory );
AuthorizeSDK . register ( String platformName , String appId , Class < IAuthorize > clazz );
The setting of global event callback is similar to the authorization SDK
call payment
PaymentSDK . pay ( MainActivity . this , platform , paydata , new OnSucceed < String >() {
@ Override
public void onSucceed ( String result ) {
// todo
}
});
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 );
The setting of global event callback is similar to the authorization SDK
...
Receiving shared 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 , Class < IShareable > clazz );
share
// 分享纯文本
ShareSDK . make ( this , text ). share ( platform );
// 分享纯图片
ShareSDK . make ( this , new MoImage ( image )). share ( platform );
// 分享图文
ShareSDK . make ( this , text , new MoImage ( image )). share ( platform );
// 分享网页链接
ShareSDK . make ( this , new MoWeb ( url ))
. withTitle ( "这是标题" )
. withDescription ( "这是摘要" )
. withThumb ( thumb )
. share ( platform , new OnSucceed < String >() {
@ Override
public void onSucceed ( String result ) {
Toast . makeText ( MainActivity . this , "分享成功" , Toast . LENGTH_LONG ). show ();
}
});
// 分享音乐
ShareSDK . make ( this , new MoMusic ( url ))
. withTitle ( "这是标题" )
. withDescription ( "这是摘要" )
. withThumb ( thumb )
. share ( platform );
Summary of 90% of the frequently asked questions about Umeng+ sharing components http://bbs.umeng.com/thread-17764-1-1.html
Preview of content that can be shared on each Umeng platform http://dev.umeng.com/social/android/share-detail#5
Detailed instructions for sharing content on different Android platforms http://wiki.mob.com/Detailed instructions for sharing content on different platforms
Sina Weibo SDK https://github.com/sinaweibosdk/weibo_android_sdk
Copyright 2017 czy1121
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.