পৃষ্ঠাসমূহ

Loading...

মঙ্গলবার, ৬ ডিসেম্বর, ২০১১

Status update in twitter using twitter4j jar file(Not complete)

package org.example.tweet;

import twitter4j.Twitter;
import twitter4j.TwitterException;
import twitter4j.TwitterFactory;
import twitter4j.auth.AccessToken;
import twitter4j.conf.ConfigurationBuilder;
import android.app.Activity;
import android.os.AsyncTask;
import android.os.Bundle;
import android.util.Log;

public class TweetActivity extends Activity {

/** Called when the activity is first created. */
@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 {
@Override
protected String doInBackground(String... urls) {
String CALLBACK_URI = "http://myapp.com";
String CONSUMER_KEY = "GyJxm2irndDCc5L2zaA";
String CONSUMER_SECRET = "9pNTI1jNr5pwzbvVpkCDlBSH6LebskiEAP7q4ZQ";
String ACCESS_TOKEN = "163882382-y4BmXvQd0cvgZ74ATRbniEvntxfZEJmO7gJ1bjTE";
String ACCESS_TOKEN_SECRET = "nSGwDgDH01bTM5uksTMBgcDLWaPv3Y5CgCO7cCVHP8";
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");

//Twitter t=new TwitterFactory().getInstance("fds","fsd");

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();
}

twitter.getAuthorization();
return "dfs";
}

@Override
protected void onPostExecute(String result) {


}
}
}

1 টি মন্তব্য:

  1. Logcat:
    12-06 22:03:40.983: D/sayfsdem(540): caught
    12-06 22:03:42.773: D/final(540): caught
    12-06 22:03:42.783: W/System.err(540): 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-06 22:03:42.783: W/System.err(540): error - Read-only application cannot POST
    12-06 22:03:42.783: W/System.err(540): request - /1/statuses/update.json
    12-06 22:03:42.783: W/System.err(540): Relevant discussions can be on the Internet at:

    উত্তরমুছুন