Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Developer
babakar
Posts: 751
Registered: ‎05-29-2012
My Device: see later

Re: Twitter is Integrated in BlackBerry

I got it working, it redirects http://Jaww.fm

i click back go to to tweet page. on click of tweet, i get your app is being authorize... i close and do same..same thing..

i go out of app, click tweet...i get the authoize page again
Please use plain text.
Developer
pankajace12
Posts: 206
Registered: ‎04-30-2011
My Device: BlackBerry Z10

Re: Twitter is Integrated in BlackBerry

Hi,

Please don't close the screen either you find that your app is being authorize or redirects the your url.

Thanks
Please use plain text.
Developer
babakar
Posts: 751
Registered: ‎05-29-2012
My Device: see later

Re: Twitter is Integrated in BlackBerry

http://s11.postimage.org/oyl2slw01/Untitled.png

its stuck like that , is authorization over? it has been re-directed to the website.. but still written above authorizing
Please use plain text.
Developer
pankajace12
Posts: 206
Registered: ‎04-30-2011
My Device: BlackBerry Z10

Re: Twitter is Integrated in BlackBerry

Hi babakar,

see, within a few second it will come back to your app screen. don't worry. let it continue.

And, let me know the status.

Thanks
Please use plain text.
Developer
babakar
Posts: 751
Registered: ‎05-29-2012
My Device: see later

Re: Twitter is Integrated in BlackBerry

hmm.... been minutes, and it doesnt come back. i am waiting though.


thanks for all the help
Please use plain text.
Developer
pankajace12
Posts: 206
Registered: ‎04-30-2011
My Device: BlackBerry Z10

Re: Twitter is Integrated in BlackBerry

[ Edited ]

HI Babakar,

I don't know why it is happening at ur end.

I have not face this issue at my end.

please give me TwitterScreen.java class

Thanks

Please use plain text.
Developer
babakar
Posts: 751
Registered: ‎05-29-2012
My Device: see later

Re: Twitter is Integrated in BlackBerry

package app.screen;

import net.rim.device.api.browser.field2.BrowserField;
import net.rim.device.api.ui.UiApplication;
import net.rim.device.api.ui.component.ButtonField;
import net.rim.device.api.ui.component.Dialog;
import net.rim.device.api.ui.component.LabelField;
import net.rim.device.api.ui.container.MainScreen;

import com.twitterapime.rest.Credential;
import com.twitterapime.xauth.Token;
import com.twitterapime.xauth.ui.OAuthDialogListener;
import com.twitterapime.xauth.ui.OAuthDialogWrapper;
import com.twitterpawan.activity.TweetGeoLocation;
import com.twitterpawan.activity.TweetToFriend;
public class TwitterScreen extends MainScreen  {

	private final String CONSUMER_KEY ="84dMabefkTHVRhRnTZHFCA";
	private final String CONSUMER_SECRET = "CEPGbE8qe0t6rGfoDskksrjlRhCyp9Mz1m4zi3KBc";
	private final String CALLBACK_URL ="http://Jaww.fm";
	private LabelField _labelStutus;
	private OAuthDialogWrapper pageWrapper = null;
	public StoreToken _tokenValue;
	ShowAuthBrowser showAuthBrowserScreen;

	public TwitterScreen()
	{
		setTitle("Twitter Integration using OAuth");

		showAuthBrowserScreen = new ShowAuthBrowser();

		add ( new ButtonField("Tweet" ) {
			protected boolean navigationUnclick(int status, int time) {

				_tokenValue = StoreToken.fetch();

				if(_tokenValue.token.equalsIgnoreCase("nothing"))
				{
					showAuthBrowserScreen.doAuth( null );
					UiApplication.getUiApplication().pushScreen(showAuthBrowserScreen);
				}
				else
				{ 
					/************************************************************/
					Token t = new Token(_tokenValue.token, _tokenValue.secret, 
							_tokenValue.userId, _tokenValue.username);
					Credential c = new Credential(CONSUMER_KEY,	CONSUMER_SECRET, t);
					
					TweetGeoLocation tgl = new TweetGeoLocation();
					String message="Geo Location.....";
					boolean done=false;
					done=tgl.doShareLocation(message, c);
					if(done == true)
					{
						Dialog.alert("Location Tweet successfully");
					}
					else
					{
						Dialog.alert( "your location is not tweet." );	
					}
					/************************************************************/
 
				}
				return true;
			}
		});
	}


	class ShowAuthBrowser extends MainScreen implements OAuthDialogListener
	{
		BrowserField b = new BrowserField();

		public ShowAuthBrowser() 
		{	
			_labelStutus = new LabelField("Your app is being authorize." );
			add(_labelStutus );
			add(b);
			pageWrapper = new BrowserFieldOAuthDialogWrapper(b,CONSUMER_KEY,CONSUMER_SECRET,CALLBACK_URL,this);
			pageWrapper.setOAuthListener(this);

		}
		public void doAuth( String pin )
		{
			try
			{
				if ( pin == null )
				{
					pageWrapper.login();
				}
				else
				{
					this.deleteAll();
					add(b);
					pageWrapper.login( pin );
				} 

			}
			catch ( Exception e )
			{
				final String message = "Error loggin Twitter: " + e.getMessage();
				Dialog.alert( message );

			}			
		}


		public void onAccessDenied(String response ) {

			System.out.println("Access denied! -> " + response );
			updateScreenLog( "Acceso denegado! -> " + response );

		}

		public void onAuthorize(final Token token) {

			final Token myToken = token;
			_tokenValue = StoreToken.fetch();
			_tokenValue.token = myToken.getToken();
			_tokenValue.secret = myToken.getSecret();
			_tokenValue.userId = myToken.getUserId();
			_tokenValue.username = myToken.getUsername();
			_tokenValue.save();

			UiApplication.getUiApplication().invokeLater( new Runnable() {

				public void run() {
					deleteAll();
					Credential c = new Credential(CONSUMER_KEY,	CONSUMER_SECRET, myToken);
					TweetToFriend tw = new TweetToFriend();
					String message="";
					boolean done=false;
					done=tw.doTweet(message, c);
					if(done == true)
					{
						Dialog.alert( "Tweet succusfully..." );
						close();	
					}
				}
			});

		}

		public void onFail(String arg0, String arg1) {
			updateScreenLog("Error authenticating user! -> " + arg0 + ", " + arg1);
		}
	}


	private void updateScreenLog( final String message )
	{
		UiApplication.getUiApplication().invokeLater( new Runnable() {

			public void run() {
				_labelStutus.setText( message );				
			}
		});
	}
   
}

 

 

Please use plain text.
Developer
pankajace12
Posts: 206
Registered: ‎04-30-2011
My Device: BlackBerry Z10

Re: Twitter is Integrated in BlackBerry

[ Edited ]

HI


check ur tweet on website. is there any tweet?

Thanks
Pawan

Please use plain text.
Developer
babakar
Posts: 751
Registered: ‎05-29-2012
My Device: see later

Re: Twitter is Integrated in BlackBerry

what do u mean? ur tweet should appear in ur account?
did any tweet appeared
Please use plain text.
Developer
babakar
Posts: 751
Registered: ‎05-29-2012
My Device: see later

Re: Twitter is Integrated in BlackBerry

so any tweet in ur account page on twitter?
Please use plain text.