本文介绍了Twitter的exception4 04:这个URI请求无效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用我的Andr​​oid application.I发送私信给用户的追随者曾尝试以下code

I want to send direct message to user's followers using my android application.I have tried following code

      String access_token = mSharedPreferences.getString(
                        Constants.PREF_KEY_OAUTH_TOKEN, "");
                // Access Token Secret
                String access_token_secret = mSharedPreferences.getString(
                        Constants.PREF_KEY_OAUTH_SECRET, "");

                ConfigurationBuilder builder = new ConfigurationBuilder();
                builder.setDebugEnabled(true);
                builder.setOAuthConsumerKey(Constants.TWITTER_CONSUMER_KEY);
                builder.setOAuthConsumerSecret(Constants.TWITTER_CONSUMER_SECRET);
                builder.setOAuthAccessToken(access_token);
                builder.setOAuthAccessTokenSecret(access_token_secret);


                TwitterFactory tf = new TwitterFactory(builder.build());
                Twitter twitter = tf.getInstance();


                DirectMessage message = null;
                try {
                    message = twitter.sendDirectMessage(
                            frndsDetails.get(position).getId(), "Hi");
                    System.out.println("Sent: " + message.getText()
                            + " to @" + message.getRecipientScreenName());

                } catch (TwitterException e) {
                    // TODO Auto-generated catch block
                    Log.e("Twitter exception", "" + e.getMessage());
                    e.printStackTrace();
                }

但得到了以下异常

But got following exception

13 02-26:48:16.287:E / Twitter的异常(707):404:的URI请求
  无效或资源请求,诸如用户,不存在。
  当所请求的格式不被支持也返回
  请求的方法。 02-26 13:48:16.287:E / Twitter的异常(707):
  消息 - 对不起,该网页不存在02-26 13:48:16.287:
  E / Twitter的异常(707):code - 34 02-26 13:48:16.397:
  W / System.err的(707):在android.view.View.performClick(View.java:3511)

是否有直接发送帮message.Please我任何其它方法。先谢谢了。

Is there any other method for sending direct message.Please help me. Thanks in advance.

推荐答案

我用下面我发送邮件直接向追随者应用code。可能这可以帮助你。

I have used following code in my application for sending direct messages to the followers. May be this can helpful to you.

StringBuilder builder = new StringBuilder();
builder.append("@").append(twitterFriendObj.screenName).append(" ");
Status status = twitter.updateStatus(builder+"Hi this is test message");

在这里我们需要发送跟随网名直接发送消息。

Here we need to send follower screen name to send direct message.

这篇关于Twitter的exception4 04:这个URI请求无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-27 22:37