我正在使用twitter 4j lib将twitter集成到我的应用程序中。我遇到的问题是,无论谁登录手机上的Twitter应用程序,它总是发布到我的Twitter帐户。 我错过了什么?
Runnable runnable = new Runnable() {
public void run() {
ConfigurationBuilder builder = new ConfigurationBuilder();
builder.setOAuthConsumerKey("fTKYDUKDKN7679sHJjdjskhsjsksRs");
builder.setOAuthConsumerSecret("dTKYDUKDKN7679sHJjdjskhsjsks");
// Access Token
String access_token = "TKYDUKDKN7679sHJjdjskhsjsks";
// Access Token Secret
String access_token_secret = "aaTKYDUKDKN7679sHJjdjskhsjsks";
AccessToken accessToken = new AccessToken(access_token, access_token_secret);
Twitter twitter = new TwitterFactory(builder.build()).getInstance(accessToken);
//twitter.getOAuthAccessToken()
// Update status
try {
twitter4j.Status response = twitter.updateStatus("updated via myapp");
Log.d("Status", "> " + response.getText());
// Error in updating status
} catch (TwitterException e) {
// TODO Auto-generated catch block
e.printStackTrace();
Log.d("Twitter Update Error", e.getMessage());
}
try {
uploadPic(file, "MY FIRST PICTURE ", twitter);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
};
Thread mythread = new Thread(runnable);
mythread.start();
答案 0 :(得分:1)
您正在对访问令牌和访问令牌密钥的值进行硬编码,这些值可能适用于您的帐户。使用您的OAuth密钥和密钥,您可以使用Sign in with Twitter flow获取用户的访问令牌和密码。