I am trying to update status to twitter using twitter4j jar file from android project but it does not work


#1

I am using android virtual device for my android application development.
Here is the Logcat file:

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.

Here is my code snippet.

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) {

    }
}

}


#2

Did you update the consumer key and secret in your app after upgrading to the read/write/DM permission level?


#3

Yes and i think my problem is (system clock is not in sync).But i don’t know how to sync the system clock( i am using windows 7 and android virtual device).please reply


#4

I’m sorry, I don’t know. You’ll need to ask Android developer support.


#5

I did everything I did, but until twitter.updatestatus(String org) method, it not work.debug to this method , got a exception named TwitterException.this is detail:
nullRelevant discussions can be on the Internet at:
http://www.google.co.jp/search?q=b2b52c28 or
http://www.google.co.jp/search?q=1c982e2d
TwitterException{exceptionCode=[b2b52c28-1c982e2d b2b52c28-1c982e03], statusCode=-1, retryAfter=-1, rateLimitStatus=null, featureSpecificRateLimitStatus=null, version=2.2.3}

note , I’m in china ,everybody known, no use facebook / twitter / Youtobe eg , in a normal way.and , do you thing is vpn problem.


#6

ah, thanks for remembering


#7

i am having problem in my twitter application, i am working through the yamba project but i
get authentication warning, Can some one please give me a directive on how to post tweets from my android application using twitters Api