无法通过Android应用程序向用户Twitter好友发送消息?

时间:2012-11-28 09:42:55

标签: android twitter

我必须通过Twitter4j API向用户的Twitter帐户发送直接消息。

 try {
                    String token =  mSharedPreferences.getString(PREF_KEY_OAUTH_TOKEN, "");
                    String secret =  mSharedPreferences.getString(PREF_KEY_OAUTH_SECRET, "");
                  Twitter twitter = new TwitterFactory().getInstance();
                        ConfigurationBuilder cb = new ConfigurationBuilder();
                        cb.setDebugEnabled(true)
                                .setOAuthConsumerKey(TWITTER_CONSUMER_KEY)
                                .setOAuthConsumerSecret(TWITTER_CONSUMER_SECRET)
                                .setOAuthAccessToken(token)
                                .setOAuthAccessTokenSecret(secret);
                        TwitterFactory tf = new TwitterFactory(cb.build());
                        twitter = tf.getInstance();
                        twitter.sendDirectMessage("Friendtwitterid", "Hi testing");
                    } catch (TwitterException te) 
                    {
                        te.printStackTrace();
                    }

但输出将是:

Failed to send a direct message: 404:The URI requested is invalid or the resource requested, such as a user, does not exists. Also returned when the requested format is not supported by the requested method.

请帮忙。

0 个答案:

没有答案