美文网首页
三方登录

三方登录

作者: 谜之龙 | 来源:发表于2017-05-18 15:13 被阅读0次

    当点击第三方登录时,先在MOB下载完,导入包后,在点击的地方写
    微博的:

       Platform weibo = ShareSDK.getPlatform(SinaWeibo.NAME);
                //回调信息,可以在这里获取基本的授权返回的信息,但是注意如果做提示和UI操作要传到主线程handler里去执行
                weibo.setPlatformActionListener(new PlatformActionListener() {
                    @Override
                    public void onError(Platform arg0, int arg1, Throwable arg2) {
                        // TODO Auto-generated method stub
                        arg2.printStackTrace();
                    }
    
                    @Override
                    public void onComplete(Platform arg0, int arg1, HashMap<String, Object> arg2) {
                        // TODO Auto-generated method stub
                        //输出所有授权信息
                        arg0.getDb().exportData();
                    }
    
                    @Override
                    public void onCancel(Platform arg0, int arg1) {
                        // TODO Auto-generated method stub
    
                    }
                });
                //authorize与showUser单独调用一个即可
                weibo.authorize();//单独授权,OnComplete返回的hashmap是空的
                weibo.showUser(null);//授权并获取用户信息
                //移除授权
                //weibo.removeAccount(true);
    

    QQ的:

      Platform qqPlatform = ShareSDK.getPlatform(QQ.NAME);
                qqPlatform.setPlatformActionListener(new PlatformActionListener() {
                    @Override
                    public void onComplete(Platform platform, int i, HashMap<String, Object> hashMap) {
    
                    }
    
                    @Override
                    public void onError(Platform platform, int i, Throwable throwable) {
    
                    }
    
                    @Override
                    public void onCancel(Platform platform, int i) {
    
                    }
                });
                qqPlatform.authorize();

    相关文章

      网友评论

          本文标题:三方登录

          本文链接:https://www.haomeiwen.com/subject/fgpsxxtx.html