您的位置:首页 > 其它

QQ登入(6)腾讯微博-获取微博用户信息,发送微博

2014-04-20 14:01 776 查看
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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: