简介

基于极验证sdk封装的插件,提供图片拼图滑块方式的验证功能。插件使用简单,一行代码调起验证对话框。

一、插件短链:

http://yyfr.net/q1v

二、源码地址:

https://github.com/apkplug/plugspace/tree/master/GeeTeamPlugUser

三、宿主配置

1 权限配置

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />

2 组件配置:无

3 其他配置:无

四、插件使用

使用url : apkplug://geeteam/rpc/start

传入参数:

firstUrl:String : 你服务端第一次验证的url

secondUrl:String : 你服务器第二次验证的url

timeout : int :请求超时

通信接口方法

void showGTDialog(Activity activity, String firstUri, String secondUri, int timeout,IGTRPCCallback callback);

IGTRPCCallback接口:

public interface IGTRPCCallback {
    void onSuccess(String msg);
    void onFail(String msg);
    void onCancel(String msg);
}

五、调用代码

BundleRPCAgent agent = new BundleRPCAgent(FrameworkFactory.getInstance().getFrame().getSystemBundleContext());

    try {
        IShowGTDialog iShowGTDialog = agent.syncCall("apkplug://geeteam/rpc/start",IShowGTDialog.class);
        if(iShowGTDialog == null){
            Log.e("null","showinterface is null");
        }
        iShowGTDialog.showGTDialog(MainActivity.this,
                "http://webapi.geelao.ren:8011/gtcap/start-mobile-captcha/",
                "http://webapi.geelao.ren:8011/gtcap/gt-server-validate/",
                5000,
                new IGTRPCCallback() {
                    @Override
                    public void onSuccess(String msg) {
                        Log.e("success",msg);
                    }

                    @Override
                    public void onFail(String msg) {
                        Log.e("fail",msg);
                    }

                    @Override
                    public void onCancel(String msg) {
                        Log.e("cancel",msg);
                    }
                });
    } catch (Throwable throwable) {
        throwable.printStackTrace();
    }

六、快速测试

可以通过如下接口一步从短链下载并测试rpc接口,短链为官方提供示例插件demo。

PlugManager.getInstance().getRPCInstanceByShortLink(true,“http://yyfr.net/q1v”, "apkplug://geeteam/rpc/start",IShowGTDialog.class, new OnGetRPCInstanceListener<IShowGTDialog>() {
        @Override
        public void onDownloadProgress(String s, String s1, long l, long l1) {

            float percent = (float)l/(float) l1;
            Log.e("progress","percent:"+percent)
                      }

        @Override
        public void onInstallSuccess(org.osgi.framework.Bundle bundle) {
            Log.e("install s",bundle.getName());
        }

        @Override
        public void onGetRPCSuccess(IShowGTDialog t) {
           t.showGTDialog(MainActivity.this,
                "http://webapi.geelao.ren:8011/gtcap/start-mobile-captcha/",
                "http://webapi.geelao.ren:8011/gtcap/gt-server-validate/",
                5000,
                new IGTRPCCallback() {
                    @Override
                    public void onSuccess(String msg) {
                        Log.e("success",msg);
                    }

                    @Override
                    public void onFail(String msg) {
                        Log.e("fail",msg);
                    }

                    @Override
                    public void onCancel(String msg) {
                        Log.e("cancel",msg);
                    }
                });


        }

        @Override
        public void onFail(String s, String s1) {
            Log.e("fail",s+" "+s1);
        }
    });