gpt4 book ai didi

android - 我正在尝试使用 twitter4j jar 将状态更新到 twitter 但它不起作用

转载 作者:行者123 更新时间:2023-11-29 14:03:26 24 4
gpt4 key购买 nike

日志:

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

我已经在我的应用程序设置中设置了读、写权限,尽管它提供了权限。

这是我的全部代码。

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

}
}
}

虽然我在我的应用程序设置中设置了读写权限,但只有我能看到它可以读取屏幕名称。提前致谢。

最佳答案

我在更改 Twitter Api 访问权限时也遇到了这个问题。

Regenerating the Access Token solved it

关于android - 我正在尝试使用 twitter4j jar 将状态更新到 twitter 但它不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8382021/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com