我试图更新状态使用twitter4j罐子里叽叽喳喳,但它不工作 [英] I am trying to update status to twitter using twitter4j jar but it does not work

查看:289
本文介绍了我试图更新状态使用twitter4j罐子里叽叽喳喳,但它不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

logcat的:

12-06 09:23:25.673: D/final(537): caught
12-06 09:23:27.003: D/userName(537): sayemsiam
12-05 12:42:20.783: W/System.err(588): 401:Authentication credentials (https://dev.twitter.com/docs/auth) were missing or incorrect. Ensure that you have set valid conumer key/secret, access token/secret, and the system clock in in sync.
12-05 12:42:20.783: W/System.err(588): error - Read-only application cannot POST
12-05 12:42:20.783: W/System.err(588): request - /1/statuses/update.json    

我已经设置阅读,在我的应用程序设置写权限,虽然它给了。

i have set read,write permission in my application settings though it gives.

下面是我的整个code。

Here is my whole code.

public class TweetActivity extends Activity {

    @Override
    public void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        ConfigurationBuilder configurationBuilder = new ConfigurationBuilder();

        // configurationBuilder.setOAuthConsumerKey(CONSUMER_KEY);
        // configurationBuilder.setOAuthConsumerSecret(CONSUMER_SECRET);

        CustomAsyncTask cm = new CustomAsyncTask();
        cm.execute(new String[] { "df" });
    }

    private class CustomAsyncTask extends AsyncTask<String, Void, String> {

                @Override
        protected String doInBackground(String... urls) {

            String CALLBACK_URI = "http://myapp.com";
            String CONSUMER_KEY = "********************";
            String CONSUMER_SECRET = "************************";
            String ACCESS_TOKEN = "*******************";
            String ACCESS_TOKEN_SECRET = "***********************";
            AccessToken ac = new AccessToken(ACCESS_TOKEN, ACCESS_TOKEN_SECRET);
            Log.d("robin", "caught");
            // Configuration configuration = configurationBuilder.build();

            // Twitter twitter = new
            // TwitterFactory(configuration).getInstance(ac);
            Twitter twitter = new TwitterFactory().getInstance();
            twitter.setOAuthConsumer(CONSUMER_KEY, CONSUMER_SECRET);
            twitter.setOAuthAccessToken(ac);
            Log.d("sayfsdem", "caught");

            try {
                twitter4j.Status status = twitter
                        .updateStatus("tihs sw th aa updatein");
                Log.d("status", status.toString());
            } catch (TwitterException e) {
                // TODO Auto-generated catch block
                Log.d("final", "caught");
                e.printStackTrace();
            }

            try {
                Log.d("userName", twitter.getScreenName());
                // Log.d("password",twitter.getFavorites()());
            } catch (IllegalStateException e) {
                Log.d("illesayem", "caught");
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (TwitterException e) {
                Log.d("fdfds", "caught");
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            return "dfs";
        }
        @Override
        protected void onPostExecute(String result) {

        }
    }
}

只有我能看到,虽然我已经在我的应用程序设置中设置的读写权限它可以读取画面名称。先谢谢了。

Only i can see that it can read the screen name though i have set read write permission in my application settings. Thanks in advance.

推荐答案

看看下面的作品中,我已经使用麻烦twitter4j.auth.AccessToken直接:

See if the following works, I've had trouble using twitter4j.auth.AccessToken directly:

ConfigurationBuilder configurationBuilder = new ConfigurationBuilder();
configurationBuilder.setOAuthConsumerKey(CONSUMER_KEY);
configurationBuilder.setOAuthConsumerSecret(CONSUMER_SECRET(;
configurationBuilder.setOAuthAccessToken(ACCESS_TOKEN);
configurationBuilder.setOAuthAccessTokenSecret(ACCESS_TOKEN_SECRET);

Configuration configuration = configurationBuilder.build();

Twitter twitter = new TwitterFactory(configuration).getInstance();

twitter.whatever(...);

这篇关于我试图更新状态使用twitter4j罐子里叽叽喳喳,但它不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆