What about friends? I write because I have a big problem, I am trying to develop a aplication to connect with twitter and post information on it any more. I have the following code, able to connect once and put my credentials. Unfortunately now I do not connect, I get that does not respond https://api.twitter.com/oauth/request_token
if anyone can help, they are GRATEFUL.
import oauth.signpost.*;
import oauth.signpost.basic.DefaultOAuthProvider;
import oauth.signpost.commonshttp.*;
import oauth.signpost.exception.*;
import twitter4j.Twitter;
import twitter4j.TwitterFactory;
import twitter4j.auth.AccessToken;
import android.app.Activity;
import android.content.*;
import android.net.Uri;
import android.os.Bundle;
import android.view.*;
import android.widget.*;
public class GoingSocialTwitterSignPostActivity extends Activity {
private static final String CONSUMER_KEY = "cPgkkrpJ0WrsxfBj3gdy1w";
private static final String CONSUMER_SECRET = "B4n4WXlvG9iYM1BnwNpN5I5WQU9VcpTehhIg1tZII";
private static final String REQUEST_URL = "https://api.twitter.com/oauth/request_token";
private static final String ACCESS_URL = "https://api.twitter.com/oauth/access_token";
private static final String AUTHORIZE_URL = "https://api.twitter.com/oauth/authorize";
private static final String CALLBACK_URL = "app://testtwitter";
private TextView codigoRespuesta;
private Button botonAutorizar;
private TextView campoTweet;
private Button botonEnviarTweet;
private CommonsHttpOAuthConsumer httpOauthConsumer;
private OAuthProvider httpOauthprovider;
private AccessToken accessToken;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
codigoRespuesta = (TextView) findViewById(R.id.codigoRespuesta);
botonAutorizar = (Button) findViewById(R.id.botonAutorizar);
campoTweet = (TextView) findViewById(R.id.tweet);
botonEnviarTweet = (Button) findViewById(R.id.botonEnviarTweet);
botonAutorizar.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
autoriza();
}
});
botonEnviarTweet.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
enviaTweet();
}
});
}
private void autoriza() {
httpOauthConsumer = new CommonsHttpOAuthConsumer(CONSUMER_KEY, CONSUMER_SECRET);
httpOauthprovider = new DefaultOAuthProvider(REQUEST_URL, ACCESS_URL, AUTHORIZE_URL);
try {
String authUrl = httpOauthprovider.retrieveRequestToken(httpOauthConsumer, CALLBACK_URL);
codigoRespuesta.setText(authUrl);
this.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(authUrl)));
} catch (OAuthMessageSignerException e) {
codigoRespuesta.setText(e.getMessage());
e.printStackTrace();
} catch (OAuthNotAuthorizedException e) {
codigoRespuesta.setText(e.getMessage());
e.printStackTrace();
} catch (OAuthExpectationFailedException e) {
codigoRespuesta.setText(e.getMessage());
e.printStackTrace();
} catch (OAuthCommunicationException e) {
codigoRespuesta.setText(e.getMessage());
e.printStackTrace();
}catch (Exception e){
codigoRespuesta.setText(e.getMessage());
e.printStackTrace();
}
}
@Override
protected void onNewIntent(Intent intent) {
//m
if anyone can help, they are GRATEFUL.
import oauth.signpost.*;
import oauth.signpost.basic.DefaultOAuthProvider;
import oauth.signpost.commonshttp.*;
import oauth.signpost.exception.*;
import twitter4j.Twitter;
import twitter4j.TwitterFactory;
import twitter4j.auth.AccessToken;
import android.app.Activity;
import android.content.*;
import android.net.Uri;
import android.os.Bundle;
import android.view.*;
import android.widget.*;
public class GoingSocialTwitterSignPostActivity extends Activity {
private static final String CONSUMER_KEY = "cPgkkrpJ0WrsxfBj3gdy1w";
private static final String CONSUMER_SECRET = "B4n4WXlvG9iYM1BnwNpN5I5WQU9VcpTehhIg1tZII";
private static final String REQUEST_URL = "https://api.twitter.com/oauth/request_token";
private static final String ACCESS_URL = "https://api.twitter.com/oauth/access_token";
private static final String AUTHORIZE_URL = "https://api.twitter.com/oauth/authorize";
private static final String CALLBACK_URL = "app://testtwitter";
private TextView codigoRespuesta;
private Button botonAutorizar;
private TextView campoTweet;
private Button botonEnviarTweet;
private CommonsHttpOAuthConsumer httpOauthConsumer;
private OAuthProvider httpOauthprovider;
private AccessToken accessToken;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
codigoRespuesta = (TextView) findViewById(R.id.codigoRespuesta);
botonAutorizar = (Button) findViewById(R.id.botonAutorizar);
campoTweet = (TextView) findViewById(R.id.tweet);
botonEnviarTweet = (Button) findViewById(R.id.botonEnviarTweet);
botonAutorizar.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
autoriza();
}
});
botonEnviarTweet.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
enviaTweet();
}
});
}
private void autoriza() {
httpOauthConsumer = new CommonsHttpOAuthConsumer(CONSUMER_KEY, CONSUMER_SECRET);
httpOauthprovider = new DefaultOAuthProvider(REQUEST_URL, ACCESS_URL, AUTHORIZE_URL);
try {
String authUrl = httpOauthprovider.retrieveRequestToken(httpOauthConsumer, CALLBACK_URL);
codigoRespuesta.setText(authUrl);
this.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(authUrl)));
} catch (OAuthMessageSignerException e) {
codigoRespuesta.setText(e.getMessage());
e.printStackTrace();
} catch (OAuthNotAuthorizedException e) {
codigoRespuesta.setText(e.getMessage());
e.printStackTrace();
} catch (OAuthExpectationFailedException e) {
codigoRespuesta.setText(e.getMessage());
e.printStackTrace();
} catch (OAuthCommunicationException e) {
codigoRespuesta.setText(e.getMessage());
e.printStackTrace();
}catch (Exception e){
codigoRespuesta.setText(e.getMessage());
e.printStackTrace();
}
}
@Override
protected void onNewIntent(Intent intent) {
//m