如何在twitter中使用android AccountManager授權?如何使用android AccountManager在twitter中授權?
AccountManager am = AccountManager.get(this);
Account[] accts = am.getAccountsByType(TWITTER_ACCOUNT_TYPE);
if(accts.length > 0) {
Account acct = accts[0];
am.getAuthToken(acct, "com.twitter.android.oauth.token"/*what goes here*/, null, this, new AccountManagerCallback<Bundle>() {
@Override
public void run(AccountManagerFuture<Bundle> arg0) {
try {
Bundle b = arg0.getResult();
Log.e("TrendDroid", "THIS AUTHTOKEN: " + b.getString(AccountManager.KEY_AUTHTOKEN));
} catch (Exception e) {
Log.e("TrendDroid", "[email protected]");
}
}}, null);
}
現在,我得到com.twitter.android.oauth.token和com.twitter.android.oauth.token.secret。但下一步是什麼?我如何使用它來授權?
我用隸API和我試圖用這樣的:
service.signRequest(new Token(token, secret), request);
但它不工作。我也嘗試了另一種不起作用的方法。 有很多類似這樣的問題:
https://dev.twitter.com/discussions/4875
https://groups.google.com/forum/?fromgroups#!topic/twitter-development-talk/1tWEx--5h9w%5B1-25%5D
http://osdir.com/ml/twitter4j/2011-06/msg00128.html
Android: How to Twitter oAuth Through Account Manager
Twitter Authentication through Android's AccountManager classes
Using account manager to get OAuth token
,沒有人給出具體的答案
你能更具體嗎?什麼不行?你有錯誤嗎?什麼是堆棧跟蹤?你在調試模式下用'scribe'試過了嗎?你給出的代碼示例中'token'和'secret'的值是多少? – 2012-08-17 18:34:46
我不建議你前進你的應用程序(對不起),因爲twitter限制了它的訪問。閱讀本文:Twitter想阻止你使用Twitter推出的Twitter應用程序http://gizmodo.com/5935517 – 2012-08-17 02:11:43
其實我只需要用戶個人資料數據.. – pleerock 2012-08-17 02:15:08