Android使用ShareSDK实现微信第三方登录中要获取unionid的方法

来源:互联网 发布:tcl网络电视如何看直播 编辑:程序博客网 时间:2024/05/14 09:12

如果使用的是ShareSDK实现微信登录的,就没有必要再看微信开放平台的文档了(因为ShareSDK已经给你做了)

  Platform plat = ShareSDK.getPlatform(context, platStr);

//获取unionid,ShareSDK没有直接的API

//1.只能使用这个方法获取所有信息的Json,
        String InfoJson = plat.getDb().exportData();

//2,解析Json

Gson gson = new Gson();
        WeiXinBean weiXinBean = gson.fromJson(json, WeiXinBean .class);(写WeiXinBean ,注意要把expiresTime、expiresIn 写成String类型)

//3,获取unionid

        String unionid = weiXinBean .getUnionid();

阅读全文
0 0