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

上一篇:LeetCode OJ 94. Binary Tree Inorder Traversal


下一篇:[SharePoint 2010]关于基于声明(Claims)的用户认证模式