What I tried:
I have already registered the application on Twitter and received the “Consumer Key” and “Secret”. Even I got different codes to enter twitter. This is what I tried:
http://thetechnib.blogspot.com/2011/01/android-sign-in-with-twitter.html
[This link is dead, you can view the archive here ]
http://www.android10.org/index.php/articleslibraries/291-twitter-integration-in-your-android-application
Problem:
Until now, the code above takes me to the twitter login and allows me to log in and have a PIN to complete the login process. But I have no idea how to use it to run my application. I checked all the code but found nothing related to the pin.
Secondly, when I registered my application on Twitter, he asked for a callback URL, but as it was written, it really is not needed, I skipped the indication. (Even I don’t know what it should be!)
And therefore, I give null as CallbackURL in my application.
Can anyone suggest to me how I can use this PIN to complete the login process and return the user to the main application of my application? Is this the callback url that is causing the problem, or is there something else I'm doing wrong?
Answer, please. Any help appriciated! Thanks.
EDIT:
As Frankenstein suggested, I tried the code at github.com/ddewaele/AndroidTwitterSample/downloads
I added my consumer key and consumer secret along with the callback url:
public static final String OAUTH_CALLBACK_SCHEME= "x-oauthflow-twitter"; public static final String OAUTH_CALLBACK_HOST= "callback"; public static final String OAUTH_CALLBACK_URL= OAUTH_CALLBACK_SCHEME + "://" + OAUTH_CALLBACK_HOST;
but he gives me this error:
Logcat:
11-29 11:56:56.249: E/com.ecs.android.sample.twitter.OAuthRequestTokenTask(3081): Error during OAUth retrieve request token 11-29 11:56:56.249: E/com.ecs.android.sample.twitter.OAuthRequestTokenTask(3081): oauth.signpost.exception.OAuthNotAuthorizedException: Authorization failed (server replied with a 401). This can happen if the consumer key was not correct or the signatures did not match. 11-29 11:56:56.249: E/com.ecs.android.sample.twitter.OAuthRequestTokenTask(3081): at oauth.signpost.AbstractOAuthProvider.handleUnexpectedResponse(AbstractOAuthProvider.java:239) 11-29 11:56:56.249: E/com.ecs.android.sample.twitter.OAuthRequestTokenTask(3081): at oauth.signpost.AbstractOAuthProvider.retrieveToken(AbstractOAuthProvider.java:189) 11-29 11:56:56.249: E/com.ecs.android.sample.twitter.OAuthRequestTokenTask(3081): at oauth.signpost.AbstractOAuthProvider.retrieveRequestToken(AbstractOAuthProvider.java:69) 11-29 11:56:56.249: E/com.ecs.android.sample.twitter.OAuthRequestTokenTask(3081): at com.ecs.android.sample.twitter.OAuthRequestTokenTask.doInBackground(OAuthRequestTokenTask.java:55) 11-29 11:56:56.249: E/com.ecs.android.sample.twitter.OAuthRequestTokenTask(3081): at com.ecs.android.sample.twitter.OAuthRequestTokenTask.doInBackground(OAuthRequestTokenTask.java:1) 11-29 11:56:56.249: E/com.ecs.android.sample.twitter.OAuthRequestTokenTask(3081): at android.os.AsyncTask$2.call(AsyncTask.java:185) 11-29 11:56:56.249: E/com.ecs.android.sample.twitter.OAuthRequestTokenTask(3081): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305) 11-29 11:56:56.249: E/com.ecs.android.sample.twitter.OAuthRequestTokenTask(3081): at java.util.concurrent.FutureTask.run(FutureTask.java:137) 11-29 11:56:56.249: E/com.ecs.android.sample.twitter.OAuthRequestTokenTask(3081): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1068) 11-29 11:56:56.249: E/com.ecs.android.sample.twitter.OAuthRequestTokenTask(3081): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:561) 11-29 11:56:56.249: E/com.ecs.android.sample.twitter.OAuthRequestTokenTask(3081): at java.lang.Thread.run(Thread.java:1096)
Also shows me a black screen when I press the TWEET button, instead of forcing me to sign up for a twitter screen.
Omg, I'll be crazy ... I’ve been trying since two days! :( please help.