/** * 删除评论,只能删除自己发布的评论 * * @param args */ public static void main(String[] args) { System.setProperty("weibo4j.oauth.consumerKey", Weibo.CONSUMER_KEY); System.setProperty("weibo4j.oauth.consumerSecret", Weibo.CONSUMER_SECRET); try { Weibo weibo = new Weibo(); weibo.setToken(args[0], args[1]); Status status = weibo.updateStatus("test4us"); Thread.sleep(1000); String sid = status.getId() + ""; System.out.println(sid + " : " + status.getText() + " " + status.getCreatedAt()); Comment comment = weibo.updateComment("comment4u", sid, null); System.out.println( comment.getId() + " : " + comment.getText() + " " + comment.getCreatedAt()); Thread.sleep(1000); weibo.destroyComment(comment.getId()); } catch (Exception e) { e.printStackTrace(); } }
public void activateClient(int clientMask) { this.clientMask |= clientMask; if (hasClientActivated(SP_SINA_WEIBO)) { sinaWeibo.setOAuthConsumer(SinaWeibo_ConsumerKey, SinaWeibo_ConsumerSecret); } }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); setContentView(R.layout.home); listView = (ListView) findViewById(R.id.lv_weibos); writeBtn = (Button) findViewById(R.id.btn_writer); userName = (TextView) findViewById(R.id.txt_wb_title); reflesh = (Button) findViewById(R.id.btn_refresh); webInstance = this; mContext = getApplicationContext(); accessInfo = InfoHelper.getAccessInfo(mContext); accessToken = accessInfo.getAccessToken(); accessSecret = accessInfo.getAccessSecret(); userId = accessInfo.getUserID(); dialog = new ProgressDialog(webInstance); dialog.setIndeterminate(false); dialog.setCancelable(true); System.setProperty("weibo4j.oauth.consumerKey", ConstantsUtils.CONSUMER_KEY); System.setProperty("weibo4j.oauth.consumerSecret", ConstantsUtils.CONSUMER_SECRET); // 得到一个weibo对象 weibo = weibo4android.androidexamples.OAuthConstant.getInstance().getWeibo(); // 设置微博的accessToken和accessSecret weibo.setToken(accessToken, accessSecret); try { user = weibo.showUser(userId); userName.setText(user.getName()); } catch (WeiboException e1) { e1.printStackTrace(); } try { // 得到weibo数据,使用WeiboAdapater进行显示 stas = weibo.getFriendsTimeline(); WeiboAdapter adapter = new WeiboAdapter(mContext, stas); listView.setAdapter(adapter); } catch (WeiboException e) { e.printStackTrace(); } reflesh.setOnClickListener( new OnClickListener() { public void onClick(View v) { Intent intent = new Intent(); intent.setClass(FriendsTimeLineActivity.this, FriendsTimeLineActivity.class); startActivity(intent); } }); writeBtn.setOnClickListener( new OnClickListener() { public void onClick(View v) { Intent intent = new Intent(); Bundle bundle = getIntent().getExtras(); if (bundle != null) { bundle.putString("thisLarge", bundle.getString("thisLarge")); bundle.putString("accessToken", accessToken); bundle.putString("accessSecret", accessSecret); bundle.putString("userId", userId); intent.putExtras(bundle); } intent.setClass(FriendsTimeLineActivity.this, JSUMainActivity.class); startActivity(intent); } }); }