1
我建立使用Oauth1.0 Android上的Twitter客戶端,我在中間Twitter客戶端的Oauth Athentication爲Android
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
OAuthConsumer consumer = new DefaultOAuthConsumer(
"CONSUMER_KEY",
"CONSUMER_CUSTOMER_KEY");
OAuthProvider provider = new DefaultOAuthProvider(
"https://api.twitter.com/oauth/request_token",
"https://api.twitter.com/oauth/access_token",
"https://api.twitter.com/oauth/authorize");
Toast.makeText(getApplicationContext(), "fetching request token", Toast.LENGTH_SHORT).show();
try
{
String authUrl = provider.retrieveRequestToken(consumer, OAuth.OUT_OF_BAND);
// Toast.makeText(getApplicationContext(), authUrl, Toast.LENGTH_SHORT).show();
String url = provider.retrieveRequestToken(consumer, OAuth.OUT_OF_BAND);
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)).setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_NO_HISTORY | Intent.FLAG_FROM_BACKGROUND);
this.startActivity(intent);
}
catch (OAuthMessageSignerException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
catch (OAuthNotAuthorizedException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
catch (OAuthExpectationFailedException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
catch (OAuthCommunicationException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
}
現在我已經能與此授權的地方卡住了,但只要我輸入我的用戶名和密碼,出現PIN碼,不發生重定向!那麼我想要的是顯示用戶的推文,而無需輸入PIN碼!我該怎麼辦 ?
由於提前
實際上回調網址的位置在哪裏,以及究竟應該放入哪個網址! B'coz從用戶的角度看,沒有人會將密碼輸入到應用程序中 – Anuj
我該如何將URL傳遞迴我的應用程序? – Anuj
請參閱[oAuth流](https://dev.twitter.com/docs/auth/oauth)使用回調URL和[此問題](http://stackoverflow.com/questions/2958701/launch-custom- android-application-from-android-browser)從瀏覽器中啓動一個應用程序 – markdsievers