如何在黑莓中发送推文

时间:2012-05-24 06:43:31

标签: blackberry twitter twitter-oauth

我想在黑莓中发推文。我在获得非法例外后能够登录。

我使用以下代码进行推文。请建议我。

protected class MyBrowserFieldListener extends BrowserFieldListener {
   public void documentLoaded(final BrowserField browserField, Document document  
        throws Exception {
        //Dialog.alert("Loaded");
        if(i==1){
            //Dialog.alert("111");
            String c=OAuth.accessToken();
            //Dialog.alert(c);
            if(c.equals("200")){
                            Token token = new Token(Const.token, Const.tokenSecret);
                Credential cj = new Credential(Const.name, 
                                   Const.consumerKey,Const.consumerSecret, token);

                                           m = UserAccountManager.getInstance(cj);

                if (m.verifyCredential()) {
                                      Const.persistentHashtable.put("Token", l);
                    Const.persistentHashtable.put("Token_Secret",   Const.tokenSecret);
                    Const.persistentHashtable.put("uam", m);
                    try{


                    Tweet t = new Tweet("jomymaratt", "Hi!!! Now I can send DM.");
                        TweetER ter = TweetER.getInstance(m);
                        t = ter.send(t);
                    }

1 个答案:

答案 0 :(得分:1)

Token token = new Token(token, tokenSecret);
Credential cj = new Credential(name, consumerKey,consumerSecret, token);
m = UserAccountManager.getInstance(cj);
  if (m.verifyCredential()
       {
          Tweet t = new Tweet("Hi!!! ");
      TweetER ter = TweetER.getInstance(m);
      t = ter.post(t); 
        } 
    else {
          Dialog.alert("Error");      
          }