[英]Twitter Login Authentication in Android?
我必須執行登錄身份驗證才能發布推文。 我從此鏈接 SignPost.jar
了Jtwitter.jar
和SignPost.jar
文件。 據我搜索,xAuth Authendication效率更高。 但是我還沒有獲得有關登錄身份驗證的任何簡單教程或代碼。 我找到了這篇文章並使用了此代碼。 多數民眾贊成在獲取NullPointerException
。
我創建了客戶密鑰,並且秘密密鑰還使用了獲得jar網站的代碼。 得到Verification Error
。
請分享一些想法或步驟,以驗證用戶名和密碼?
編輯:
我想從user's account
發布到。 您更喜歡使用Api是Jtwitter
還是Oauth
? 並告訴我How-to
或Related Articles
?
這是在Android中為Twitter實現OAuth的一個很好的例子
Brion Emde的http://github.com/brione/Brion-Learns-OAuth
這部影片
JTwitter是基本autentication,避免在8月16日的Twitter aunthentication的OAuthocalypse即將改變http://www.4psmarketing.com/blog/world-cup-2010-delays-twitter-oauthocalypse
@Jorgesys-您錯誤地說“ JTwitter用於基本身份驗證”。 JTwitter支持OAuth,示例代碼顯示正在使用的OAuth。 請參閱JTwitter文檔
xAuth對用戶不利,因為您需要收集用戶密碼。 如果要使用xAuth,則必須向Twitter支持尋求許可。
因此,OAuth可能需要更多工作,但這是最好的選擇。
在Android上,您需要將用戶定向到身份驗證頁面。 下面的代碼應該工作。 如果可以處理回調,則可以使事情變得更順暢。
// Make an oauth client
// "oob" is for the slightly clunky enter-your-pin method
OAuthSignpostClient oauthClient = new OAuthSignpostClient(MY_OAUTH_KEY, MY_OAUTH_SECRET, "oob");
// open the authorisation page in the user's browser
URI url = client.authorizeUrl();
Intent myIntent = new Intent(Intent.VIEW_ACTION);
myIntent.setData(url);
startActivity(myIntent);
// TODO Get the pin from the user
String pinCode;
oauthClient.setAuthorizationCode(pinCode);
// Store the authorisation token details for future use
Object accessToken = client.getAccessToken();
// Make a Twitter object
Twitter twitter = new Twitter("my-name", oauthClient);
// Set your status
twitter.setStatus("Messing about in Java");
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.