zoukankan      html  css  js  c++  java
  • QQ登入(6)腾讯微博-获取微博用户信息,发送微博

    1.1获取weibo用户信息

     //先登入授权,可以参考QQ登入(1)
            Weibo    mWeibo = new Weibo(this, mQQAuth.getQQToken());
            mWeibo.getWeiboInfo(new TQQApiListener("get_info", false,MyQQloginShareActivity.this));

    1.2.添加结果监听

        private class TQQApiListener implements IUiListener {
            public TQQApiListener(String scope, boolean needReAuth,
                    Activity activity) {
            }
            @Override
            public void onComplete(Object response) {
             Log.i("mylog",response.toString());
             }
    
            @Override
            public void onCancel() {
                // TODO Auto-generated method stub
                
            }
    
            @Override
            public void onError(UiError arg0) {
                // TODO Auto-generated method stub
                
            }
        }

    2,1发送纯文字微博

     //先登入授权,可以参考QQ登入(1)
            Weibo    mWeibo = new Weibo(this, mQQAuth.getQQToken());
            mWeibo.getWeiboInfo(new TQQApiListener("get_info", false,MyQQloginShareActivity.this));
            String content = "test add tweet";
            mWeibo.sendText(content, new TQQApiListener("add_t", false,MyQQloginShareActivity.this));

    2.2 监听结果,可参考本文1.2

    3.1发送带本地图片微博

    打开本地相册

            Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
            intent.addCategory(Intent.CATEGORY_OPENABLE);
            intent.setType("image/*");
            startActivityForResult(intent, 123);//123可以自定义返回值

    3.2 获取返回值,转换绝对路径,发送微博

        @Override
        protected void onActivityResult(int requestCode, int resultCode, Intent data) {
            if (data != null) {
                if (requestCode == 123) {//与上面对应
                       String filePath = SystemUtils.getRealPathFromUri(this, data.getData());
                    Weibo    mWeibo = new Weibo(this, mQQAuth.getQQToken());
                    mWeibo.getWeiboInfo(new TQQApiListener("get_info", false,MyQQloginShareActivity.this));
                    mWeibo.sendPicText("互联sdk测试发送微博", filePath,new TQQApiListener("add_t", false,MyQQloginShareActivity.this));
                }
            }
        }

     源码:链接: http://pan.baidu.com/s/1qWwJQ24 

  • 相关阅读:
    轨迹纠偏算法
    OpenStreetMap
    postgres create new super user
    postgis docker
    scala 命令台参数解析
    book
    Microsoft 365:OneDrive新特性,跨部门共享和协作
    2020年6月Microsoft 365 新功能速递
    Microsoft 365 解决方案:未经身份验证的用户上载文档小技巧 (2)
    Microsoft 365 解决方案:外部用户无法打开Microsoft Teams下录制的视频
  • 原文地址:https://www.cnblogs.com/clarence/p/3676365.html
Copyright © 2011-2022 走看看