Cómo verificar callback_url en la aplicación twitter

Tengo un montón de ejemplos para O_Auth pero nadie está funcionando correctamente y supongo que lo único que es la URL de devolución de llamada en cada ejemplo, estoy recibiendo error 401 como la clave del consumidor o la firma no coinciden. Ya he visto tantos ejemplos en 401 la única cosa que entra en mi favor es mi URL de devolución de llamada.

La aplicación android no puede conectarse a twitter . Obtener 401 al solicitar token de acceso con signpost dentro de androide con-signpost-android Android Dev – URL de devolución de llamada no funciona … (0_o)

Ya he visto todos estos ejemplos y muchos más.

Pero aún no estoy recibiendo mi punto, Si en el momento de la solicitud de formulario que uso http://www.meomyo.com en la URL de devolución de llamada, Entonces, ¿qué debo utilizar en mi codificación como android: scheme = "?" Android: host = "?" Currrently estoy usando otros ejemplos callbacks

//private static final Uri CALLBACK_URI = Uri.parse("bloa-app://twitt"); private static final Uri CALLBACK_URI = Uri.parse("twitterapp://connect"); 

Tengo clave del consumidor también clave secreta, pero en caso de URL de devolución de llamada estoy atascado en él. Si alguien quiere puedo proporcionar a mi consumidor, así clave secreta.

 public class OAuth extends Activity { private static final String APP = "OAUTH"; private Twitter twitter; private OAuthProvider provider; private CommonsHttpOAuthConsumer consumer; private String CONSUMER_KEY = "Xh3o8Gh1JQnklkUnTvvA"; private String CONSUMER_SECRET = "SCLy6yoUSth53goAsYYkoqR4ZuBoaInyJXsm5PQR11I"; private String CALLBACK_URL = "merabharatmahan://piyush"; private TextView tweetTextView; private Button buttonLogin; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); tweetTextView = (TextView)findViewById(R.id.tweet); buttonLogin = (Button)findViewById(R.id.ButtonLogin); buttonLogin.setOnClickListener(new OnClickListener() { public void onClick(View v) { askOAuth(); } }); } /** * Open the browser and asks the user to authorize the app. * Afterwards, we redirect the user back here! */ private void askOAuth() { try { consumer = new CommonsHttpOAuthConsumer(CONSUMER_KEY, CONSUMER_SECRET); provider = new DefaultOAuthProvider("http://twitter.com/oauth/request_token", "http://twitter.com/oauth/access_token", "http://twitter.com/oauth/authorize"); String authUrl = provider.retrieveRequestToken(consumer, CALLBACK_URL); Toast.makeText(this, "Please authorize this app!", Toast.LENGTH_LONG).show(); this.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(authUrl))); } catch (Exception e) { Log.e(APP, e.getMessage()); Toast.makeText(this, e.getMessage(), Toast.LENGTH_LONG).show(); } } /** * As soon as the user successfully authorized the app, we are notified * here. Now we need to get the verifier from the callback URL, retrieve * token and token_secret and feed them to twitter4j (as well as * consumer key and secret). */ @Override protected void onNewIntent(Intent intent) { super.onNewIntent(intent); Uri uri = intent.getData(); if (uri != null && uri.toString().startsWith(CALLBACK_URL)) { String verifier = uri.getQueryParameter(oauth.signpost.OAuth.OAUTH_VERIFIER); try { // this will populate token and token_secret in consumer provider.retrieveAccessToken(consumer, verifier); // TODO: you might want to store token and token_secret in you app settings!!!!!!!! AccessToken a = new AccessToken(consumer.getToken(), consumer.getTokenSecret()); // initialize Twitter4J twitter = new TwitterFactory().getInstance(); twitter.setOAuthConsumer(CONSUMER_KEY, CONSUMER_SECRET); twitter.setOAuthAccessToken(a); // create a tweet Date d = new Date(System.currentTimeMillis()); String tweet = "#OAuth working! " + d.toLocaleString(); // send the tweet twitter.updateStatus(tweet); // feedback for the user... tweetTextView.setText(tweet); Toast.makeText(this, tweet, Toast.LENGTH_LONG).show(); buttonLogin.setVisibility(Button.GONE); } catch (Exception e) { Log.e(APP, e.getMessage()); Toast.makeText(this, e.getMessage(), Toast.LENGTH_LONG).show(); } } } 

}

Código manifiesto es

 <application android:icon="@drawable/icon" android:label="@string/app_name"> <activity android:name=".OAuth" android:label="@string/app_name" android:launchMode="singleInstance"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> <intent-filter> <action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.BROWSABLE" /> <data android:scheme="merabharatmahan" android:host="piyush" /> </intent-filter> </activity> </application 

Ahora estoy recibiendo la comunicación con el proveedor de servicios ha fallado: Desafío de autenticación recibido es nulo. Es el ejemplo más sencillo que pongo aquí.

Twitterapp: // connect es tu url de llamada de vuelta.

En Android manifest.xml define tu actividad de la siguiente manera:

 <activity android:name=".auth.SocialNetworkActivity" android:configChanges="orientation" android:label="Connect SNS" android:launchMode="singleTask"> <intent-filter> <action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.BROWSABLE" /> <data android:scheme="twitterapp" android:host="connect" /> </intent-filter> </activity> 

Ahora, se abrirá la página web de twitter, y en la autenticación exitosa, se llamará a su método de devolución de llamada onNewIntent ().

En el ejemplo anterior, utilice su propio nombre de actividad.

Aparte de eso, la integración de twitter en mi aplicación se hace usando twitter4j.

Usted debe poner lo que usted piensa será único:

 android:scheme="name-of-your-dog" android:host="something-else" 

Oh, espere … tal vez hay alguien que posee un perro llamado como el suyo … así que, use el nombre del paquete de su aplicación:

 android:scheme="com.your.package" android:host="something-else" 

Y, si no funciona para usted … No creo que esté relacionado con la URL de devolución de llamada. ¿Cómo declaras tu actividad en el manifiesto? Has añadido el parámetro android:launchMode="singleTask" , ¿no?

Y, como el tipo zombie señaló, debe manejar la devolución de llamada en el método onNewIntent de su actividad de autenticación. Algo como esto:

 final Uri uri = intent.getData(); if (uri != null && uri.getScheme().equals("name-of-your-dog")) { //etc... } 
FlipAndroid es un fan de Google para Android, Todo sobre Android Phones, Android Wear, Android Dev y Aplicaciones para Android Aplicaciones.