@Override public void sendWeibo(SocialUserAccount socialUserAccount, String text, String type) { String accountId = socialUserAccount.getId(); OAuthV2 oAuth = queryAccountToken(accountId); int ret = 0; TAPI tAPI = new TAPI(oAuth.getOauthVersion()); // 根据oAuth配置对应的连接管理器 try { String response = tAPI.add(new AddParameter(oAuth, text)); ret = 1; } catch (Exception e) { e.printStackTrace(); } if (ret == 1) { saveSendWeiboRecord(socialUserAccount, text, type); } }
/** 评论 */ @Override public int discussWeibo(WeiboForwardSend weiboForwardSend) { String accountId = weiboForwardSend.getUserAccountId(); OAuthV2 oAuth = queryAccountToken(accountId); int ret = 0; TAPI tAPI = new TAPI(oAuth.getOauthVersion()); // 根据oAuth配置对应的连接管理器 try { String response = tAPI.comment( new AddParameter(oAuth, weiboForwardSend.getContent(), weiboForwardSend.getWeibId())); boolean isRplyOk = JSONObject.fromObject(response).getString("msg").equals("ok"); if (isRplyOk) { ret = 1; } } catch (Exception e) { e.printStackTrace(); } return ret; }
@Override public void run() { message = new Message(); String response = null; TAPI tAPI = null; tAPI = new TAPI(OAuthConstants.OAUTH_VERSION_2_A); try { response = tAPI.addPic(oAuthV2, "json", textString, "127.0.0.1", imagePath); tAPI.shutdownConnection(); if (null != response) { message.what = SUCCESS; handler.sendMessage(message); } else { message.what = IOEXCEPTION; handler.sendMessage(message); } } catch (Exception e) { message.what = IOEXCEPTION; handler.sendMessage(message); } super.run(); }